waiter waiting on a waiter

Jul 28, 2011 at 8:15 PM
 
public event EventHandler Proceed1;

 private void button1_Click(object sender, EventArgs e)
{
            new EventWaiter(Func1);
}

IEnumerable<bool> Func1(EventWaiter waiter)
{
            
            new EventWaiter(Func2);
            yield return waiter.Wait(this, "Proceed1");

            // have to wait here for the below code to execute...

            int a,b,c
            a =2;
            b =2;
            c = a + b;
}

IEnumerable<bool> Func2(EventWaiter waiter)
{

           // show user a simulated inputBox
           ShowInputBox("prompt", "default value");
            
           // this yield waits for some external event to happen, once the user clicks ok on the inputbox
            yield return waiter.WaitForUserInput();

          int d,e,f;
          d = 5;
          e = 5;
          f = 5 * 5;

          Proceed1(null, null);
        }

Can the above be implemented easier?  Basically I need my Func2 to execute to completion before Func1 can continue...