BaoKai_202508-Wms-Jingwang..../ServerSystem/Program.cs
2025-08-24 09:35:55 +08:00

57 lines
1.9 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ServerSystem
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//Application.EnableVisualStyles();
//Application.SetCompatibleTextRenderingDefault(false);
//Application.Run(new FrmSytem());
try
{
#region :使
bool createNew;
// createdNew:
// 在此方法返回时,如果创建了局部互斥体(即,如果 name 为 null 或空字符串)或指定的命名系统互斥体,则包含布尔值 true
// 如果指定的命名系统互斥体已存在则为false
using (Mutex mutex = new Mutex(true, Application.ProductName, out createNew))
{
if (createNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmSytem());
}
// 程序已经运行的情况,则弹出消息提示并终止此次运行
else
{
MessageBox.Show("立体库控制系统已经在运行中...");
System.Threading.Thread.Sleep(1000);
// 终止此进程并为基础操作系统提供指定的退出代码。
System.Environment.Exit(1);
}
}
#endregion
}
catch (Exception ex)
{
MessageBox.Show("系统启动异常:" + ex.Message);
}
}
}
}