fix(dialogs): keep a failing cancel in the title-bar close handler from ending the app
OnClosing is async void, so an exception from the view model's cancel path was unobserved and crashed the process. It is now logged and the dialog stays open.
This commit is contained in:
1 parent
a7b07db034
commit
2932352220
1 file changed
+7
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Threading;
|
||||
using Avalonia.VisualTree;
|
||||
@@ -85,6 +86,12 @@ public class DialogWindow : Window
|
||||
{
|
||||
await _viewModel.RequestCancelAsync();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
// An async void handler must not let a failure escape and end the
|
||||
// process; the dialog simply stays open.
|
||||
Debug.WriteLine(exception);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_cancelPending = false;
|
||||
|
||||
Reference in new issue
Block a user