-
-
Notifications
You must be signed in to change notification settings - Fork 469
Closed
Description
Hello,
I have a WPF project (.NET 9) that worked well with Puppeteer until the latest update to v20.1.0. It still functions correctly, but if an HTML-to-PDF conversion is performed at least once, I get the following exception when closing the app:
A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (Target closed (Session closed))
In my App.xaml.cs, I have the following code:
public App()
{
TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
}
private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
MessageBox.Show(e.Exception.Message);
e.SetObserved();
}
This issue occurs only when the MainWindow has closing logic. Here’s my Window_Closing event handler:
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
try
{
if (Tabs.Items.Count > 1)
{
var CloseWarning = new YesNo("Exit", "Are you sure you want to exit?")
{
Owner = this
};
CloseWarning.ShowDialog();
if (!CloseWarning.Selected)
{
e.Cancel = true;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
However, even this simple closing event also causes the same exception:
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
Downgrading to v20.0.5 fixed the issue.
KozakSergii
Metadata
Metadata
Assignees
Labels
No labels