i have done some testing on catching the exceptions at the AddOnFramework-sample and i wondered that sometimes the code gets them and sometimes not. I found out that's because of the Dispatcher.InvokeAsync():
At mehods of the following structure:
private void OnSomething(object sender, EventArgs eArgs)
{
try
{
Dispatcher.InvokeAsync(() =>
{
throw new Exception("Test-Exception");
// Do Something
}
}
catch (Exception exception)
{
Dispatcher.InvokeAsync(() =>
{
Output.Process(exception.ToString(), PrintTo.OutputTab1);
}
}
}
private void OnSomething(object sender, EventArgs eArgs)
{
Dispatcher.InvokeAsync(() =>
{
try
{
throw new Exception("Test-Exception");
// Do Something
}
catch (Exception exception)
{
Output.Process(exception.ToString(), PrintTo.OutputTab1);
}
});
}
I dont know if that method (InvokeAsync() BEFORE try-catch) is a correct way to handle this problem.
Please give me some thoughts about that...
Thanks, GoS
Comment