This is the script I'm trying to ahieve (using CodeDomProvider to compile and run).

```
AddText("Testing. Press yes to continue.");
var answer = SendYesNo();

if (answer)
{
    AddText("Good.");
    SendOk();
} 
else
{
    AddText("Not good.");
    SendOk();
}

```

Now. I want SendYesNo to use a AutoResetEvent, so it halts the script execution until a response has been given. Once a response is set, the auto reset event is also set, so it continues execution and returns the response. For example, what I have so far:

```
public bool SendYesNo()
    {
        this.waitHandle = new AutoResetEvent(false);
        this.waitHandle.WaitOne();

        return this.Selection;
    }

```

And to set the selection, I use:

```
public void SetSelection(bool selection)
    {
        this.Selection = selection;
        this.waitHandle.Set();
    }

```

However, it doesn't work (nothing happens once I set the response), and the whole program is stuck. Nothing functions. Why's that? I think I have to use async for that, but I'm not sure how. Also, should I use a custom EventHandler for this?

Thanks.