From 7e04b83728eb3706cae2640e476036071b4a9abc Mon Sep 17 00:00:00 2001
From: Vova <3emaster@gmail.com>
Date: Sun, 28 Jan 2024 20:19:49 +0200
Subject: [PATCH] show general error
---
TV Player WPF/App.xaml.cs | 20 ++++++++++++++++++++
TV Player WPF/TV Player WPF.csproj | 1 +
2 files changed, 21 insertions(+)
diff --git a/TV Player WPF/App.xaml.cs b/TV Player WPF/App.xaml.cs
index 36068fa..a67111b 100644
--- a/TV Player WPF/App.xaml.cs
+++ b/TV Player WPF/App.xaml.cs
@@ -1,4 +1,5 @@
using System.Windows;
+using System.Windows.Controls.Primitives;
using TV_Player.ViewModels;
namespace TV_Player
@@ -9,13 +10,32 @@ namespace TV_Player
public partial class App : Application
{
private TVPlayerViewModel _tvPlayer;
+
+ private const string Guid = "250C5597-BA73-40DF-B2CF-DD644F044834";
+ static readonly Mutex Mutex = new Mutex(true, "{" + Guid + "}");
protected override void OnStartup(StartupEventArgs e)
{
+ AppDomain.CurrentDomain.UnhandledException += ReportAndRestart;
+
+ if (!Mutex.WaitOne(TimeSpan.Zero, true))
+ {
+ MessageBox.Show("Programm already running");
+ Current.Shutdown();
+ }
+
_tvPlayer = new TVPlayerViewModel();
base.OnStartup(e);
}
+ protected void ReportAndRestart(object sender, UnhandledExceptionEventArgs e)
+ {
+
+ string info = e.ExceptionObject.ToString();
+ MessageBox.Show(info,"Application");
+
+ Environment.Exit(1);
+ }
protected override void OnExit(ExitEventArgs e)
{
_tvPlayer = null;
diff --git a/TV Player WPF/TV Player WPF.csproj b/TV Player WPF/TV Player WPF.csproj
index 46b9fae..c23d128 100644
--- a/TV Player WPF/TV Player WPF.csproj
+++ b/TV Player WPF/TV Player WPF.csproj
@@ -20,6 +20,7 @@
+