-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.xaml.cs
More file actions
31 lines (29 loc) · 1013 Bytes
/
Copy pathApp.xaml.cs
File metadata and controls
31 lines (29 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System.Threading;
using System.Windows;
namespace Launcher
{
/// <summary>
/// Логика взаимодействия для App.xaml
/// </summary>
public partial class App
{
private static Mutex _instanceMutex;
protected override void OnStartup(StartupEventArgs e)
{
_instanceMutex = new Mutex(true, "F37E84CB-D76A-49B1-A1AC-80870903087B", out var createdNew);
if (!createdNew)
{
MessageBox.Show("Копия лаунчера уже запущена на данном компьютере", "Попытка повторного запуска", MessageBoxButton.OK, MessageBoxImage.Warning);
_instanceMutex = null;
Current.Shutdown();
return;
}
base.OnStartup(e);
}
protected override void OnExit(ExitEventArgs e)
{
_instanceMutex?.ReleaseMutex();
base.OnExit(e);
}
}
}