I'm having trouble with the async CTP, trying to figure out what the correct way to handle exceptions is. The code below crashes my program, when as far as I can tell, the await
should be catching and rethrowing the exception in the context it is called from, so the Not caught!
block should catch the exception.
try {
await TaskEx.Run(() => {
throw new Exception();
});
} catch {
// Not caught!
}
Thanks for any help or suggestions.
Works fine for me using the beta (rather than the CTP, hence the
TaskEx
becomingTask
):Output:
What does the same code do on your machine?