using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace GetData_PLC { static class Program { /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //frmMain frmMainSingle = frmMain.getSingle(); //Application.Run(frmMainSingle); bool createdNew; Mutex instance = new Mutex(true, "互斥名(保证在本机中唯一)", out createdNew); if (createdNew) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new frmMain()); instance.ReleaseMutex(); } else { MessageBox.Show("已经启动了一个程序,请先退出!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } } }