While I was writing some async code in .NET 4.5, I decided to add some exception handling. So I created a try/catch block and wanted to show a message dialog when an exception occurs.
However when I added an await to wait for the message dialog result, the compiler started throwing exceptions:
The error message stated: “Cannot await in the body of a catch clause.”
I solved it by introducing a flag bool
exceptionOccurred=false; and setting it to true in the catch block. After the catch clause I added some code to check if the flag is true.
await new MessageDialog().ShowAsync();
Anyone with a cleaner solution?