AIParkingApplication/AIParkingApplication/Program.cs

37 lines
1.2 KiB
C#

using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
namespace AIParkingApplication
{
public static class Program
{
[STAThread]
public static void Main()
{
using (Mutex mutex = new Mutex(true, "AIParkingApplication", out bool isAppCreatedNew))
{
if (isAppCreatedNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new LoginForm());
}
else
{
Process currentProcess = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcessesByName(currentProcess.ProcessName))
{
if (process.Id != currentProcess.Id)
{
MessageBox.Show(AppConstant.APPLICATION_IS_RUNNNING, AppConstant.ERROR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
break;
}
}
}
}
}
}
}