Add alert if database load fails

Task is executed without reporting exceptions; continue after the task with another that checks if it failed.
This commit is contained in:
Kurt 2020-11-28 14:53:32 -08:00
parent 8778d8c6b7
commit 0eb7bf7a4b

View file

@ -79,7 +79,17 @@ namespace PKHeX.WinForms
// Load Data
B_Search.Enabled = false;
L_Count.Text = "Loading...";
new Task(LoadDatabase).Start();
var task = new Task(LoadDatabase);
task.ContinueWith(z =>
{
if (!z.IsFaulted)
return;
Invoke((MethodInvoker)(() => L_Count.Text = "Failed."));
if (z.Exception == null)
return;
WinFormsUtil.Error("Loading database failed.", z.Exception.InnerException ?? new Exception(z.Exception.Message));
});
task.Start();
Menu_SearchSettings.DropDown.Closing += (sender, e) =>
{