mirror of
https://github.com/knah/VRCMelonAssistant.git
synced 2024-05-17 10:52:16 +12:00
Handle failing tasks that are not awaited
This commit is contained in:
parent
f755fc8b4a
commit
4b69295fda
|
@ -1,4 +1,5 @@
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
|
|
||||||
|
@ -33,5 +34,16 @@ namespace VRCMelonAssistant
|
||||||
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
|
Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void NoAwait(this Task task)
|
||||||
|
{
|
||||||
|
task.ContinueWith(t =>
|
||||||
|
{
|
||||||
|
if (t.IsFaulted)
|
||||||
|
{
|
||||||
|
Utils.ShowErrorMessageBox("Exception in free-floating task", t.Exception);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,6 +409,12 @@ namespace VRCMelonAssistant
|
||||||
caller.BeginInvoke(Message, null, null, null);
|
caller.BeginInvoke(Message, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ShowErrorMessageBox(string title, Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(MainWindow.Instance, $"{title}\n{ex}", "Error",
|
||||||
|
MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to write the specified string to the <see cref="System.Windows.Clipboard"/>.
|
/// Attempts to write the specified string to the <see cref="System.Windows.Clipboard"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace VRCMelonAssistant
|
||||||
Main.Content = Intro.Instance;
|
Main.Content = Intro.Instance;
|
||||||
break;
|
break;
|
||||||
case "Mods":
|
case "Mods":
|
||||||
ShowModsPage();
|
ShowModsPage().NoAwait();
|
||||||
break;
|
break;
|
||||||
case "About":
|
case "About":
|
||||||
Main.Content = About.Instance;
|
Main.Content = About.Instance;
|
||||||
|
@ -137,7 +137,7 @@ namespace VRCMelonAssistant
|
||||||
|
|
||||||
private void ModsButton_Click(object sender, RoutedEventArgs e)
|
private void ModsButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ShowModsPage();
|
ShowModsPage().NoAwait();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void IntroButton_Click(object sender, RoutedEventArgs e)
|
private void IntroButton_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue