I'm trying to deal with exceptions inside of tasks, so far I've looked at the following links:
How to handle Task.Run Exception
If I am correct, they suggest that the following code would not cause a User-Unhandled Exception.
public async void TestMethod()
{
try
{
await Task.Run(() => { throw new Exception("Test Exception"); });
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
However, I am getting a User-Unhandled Exception. I want to handle the exception outside of the Task so I can avoid writing code for changing the UI from a different thread. What am I doing wrong?
Here is a printscreen of the exception: