Files
ENIG/Cs_HMI/Project/Program.cs
2025-01-07 16:08:02 +09:00

65 lines
2.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Resources;
using System.Threading;
namespace Project
{
static class Program
{
/// <summary>
/// 해당 응용 프로그램의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
//중복실행방지
var guidAttr = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), true);
if (guidAttr != null)
{
var guida = (GuidAttribute)guidAttr[0];
var guidstr = guida.Value;
Mutex mtx = new Mutex(true, guidstr);
var success = mtx.WaitOne(new TimeSpan(0, 0, 1));
if (success == false)
{
MessageBox.Show("중복실행 불가\n\n프로그램이 실행 중 입니다");
return;
}
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
//AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
Application.Run(new fMain());
}
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
string emsg = "Fatal Error(UHE)\n\n" + e.ExceptionObject.ToString();
PUB.log.AddE(emsg);
PUB.log.Flush();
Util.SaveBugReport(emsg);
var f = new fErrorException(emsg);
f.ShowDialog();
Application.ExitThread();
}
static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
string emsg = "Fatal Error(ATE)\n\n" + e.Exception.ToString();
PUB.log.AddE(emsg);
PUB.log.Flush();
Util.SaveBugReport(emsg);
var f = new fErrorException(emsg);
f.ShowDialog();
Application.ExitThread();
}
}
}