Perfect Thomas, installing ShutdownMode in OnMainWindowClose, as you said, solved my problem. Now the debugger stops correctly;) Many thanks for the help.
What I've done:
<Application xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x:Class="GParts.App" StartupUri="WinMain.xaml" ShutdownMode="OnMainWindowClose"> <...> </Application>
Finally, I would like to make one remark for the backgroundworker in the DoWork event in case the exception is raised by some type of error: I hanlde the errors inside it with the try catch clause and in the catch that I do:
catch (Exception ex) { e.Result = ex.Message; }
When the background worker finishes with an exception, I want RunWorkerCompleted to detect it with e.Error and show it. So what I do in RunWorkerCompleted:
if (e.Cancelled) { // Cancelled } else if (e.Error != null) { // Exception Thrown // Here I want to show the message that produced the exception in DoWork // event. If I set e.Result = ex.Message in DoWork event, is e.Error here // containing ex.Message? } else { // Completed); }
Is e.Error in RunWorkerCompleted containing ex.Message?
Thanks.
source share