2020-06-01 20:19:20 +00:00
|
|
|
|
using Quasar.Client.IO;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Threading;
|
2018-10-05 21:58:09 +00:00
|
|
|
|
using System.Windows.Forms;
|
2014-07-08 12:58:53 +00:00
|
|
|
|
|
2018-09-27 08:05:10 +00:00
|
|
|
|
namespace Quasar.Client
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2015-04-21 18:27:52 +00:00
|
|
|
|
internal static class Program
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2020-06-01 20:19:20 +00:00
|
|
|
|
[STAThread]
|
2015-01-13 18:29:11 +00:00
|
|
|
|
private static void Main(string[] args)
|
2014-07-08 12:58:53 +00:00
|
|
|
|
{
|
2020-05-20 21:08:58 +00:00
|
|
|
|
// enable TLS 1.2
|
|
|
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
|
|
|
|
2020-06-01 20:19:20 +00:00
|
|
|
|
// Set the unhandled exception mode to force all Windows Forms errors to go through our handler
|
|
|
|
|
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
|
|
|
|
|
|
|
|
|
// Add the event handler for handling UI thread exceptions
|
|
|
|
|
Application.ThreadException += HandleThreadException;
|
|
|
|
|
|
|
|
|
|
// Add the event handler for handling non-UI thread exceptions
|
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += HandleUnhandledException;
|
|
|
|
|
|
2015-01-13 18:29:11 +00:00
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
2020-06-01 20:19:20 +00:00
|
|
|
|
Application.Run(new QuasarApplication());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void HandleThreadException(object sender, ThreadExceptionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine(e);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string batchFile = BatchFile.CreateRestartBatch(Application.ExecutablePath);
|
|
|
|
|
|
|
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
WindowStyle = ProcessWindowStyle.Hidden,
|
|
|
|
|
UseShellExecute = true,
|
|
|
|
|
FileName = batchFile
|
|
|
|
|
};
|
|
|
|
|
Process.Start(startInfo);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
2020-05-27 20:21:40 +00:00
|
|
|
|
{
|
2020-06-01 20:19:20 +00:00
|
|
|
|
Debug.WriteLine(exception);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handles unhandled exceptions by restarting the application and hoping that they don't happen again.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender">The source of the unhandled exception event.</param>
|
|
|
|
|
/// <param name="e">The exception event arguments. </param>
|
|
|
|
|
private static void HandleUnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.IsTerminating)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine(e);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string batchFile = BatchFile.CreateRestartBatch(Application.ExecutablePath);
|
|
|
|
|
|
|
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo
|
|
|
|
|
{
|
|
|
|
|
WindowStyle = ProcessWindowStyle.Hidden,
|
|
|
|
|
UseShellExecute = true,
|
|
|
|
|
FileName = batchFile
|
|
|
|
|
};
|
|
|
|
|
Process.Start(startInfo);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine(exception);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Environment.Exit(0);
|
|
|
|
|
}
|
2020-05-27 20:21:40 +00:00
|
|
|
|
}
|
2015-01-13 18:29:11 +00:00
|
|
|
|
}
|
2014-07-08 12:58:53 +00:00
|
|
|
|
}
|
2020-05-26 20:43:49 +00:00
|
|
|
|
}
|