-
-
Notifications
You must be signed in to change notification settings - Fork 492
/
Copy pathProgram.cs
56 lines (49 loc) · 1.66 KB
/
Program.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// Copyright Fela Ameghino 2015-2023
//
// Distributed under the GNU General Public License v3.0. (See accompanying
// file LICENSE or copy at https://www.gnu.org/licenses/gpl-3.0.txt)
//
using System;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using Windows.Storage;
namespace Telegram.Stub
{
static class Program
{
#if DEBUG
const string MUTEX_NAME = "TelegramBridgeMutexV2";
#else
const string MUTEX_NAME = "UnigramBridgeMutexV2";
#endif
static readonly Mutex _mutex = new Mutex(true, MUTEX_NAME);
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
if (_mutex.WaitOne(0, true))
{
Application.ThreadException += OnThreadException;
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new BridgeApplicationContext());
_mutex.ReleaseMutex();
}
}
private static void OnThreadException(object sender, ThreadExceptionEventArgs e)
{
File.WriteAllText(ApplicationData.Current.LocalFolder.Path + "\\stub.txt", e.Exception.ToString());
Application.Exit();
}
private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
File.WriteAllText(ApplicationData.Current.LocalFolder.Path + "\\stub.txt", e.ExceptionObject.ToString());
Application.Exit();
}
}
}