关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

Keep Windows Forms Singleton via Mutex key word

发布时间:2020-03-18 00:00:00
using System;using System.Collections.Generic;using System.Linq;using System.Threading;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication3
{static class Program
    {/// /// The main entry point for the application.///         [STAThread]static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);const string appName = "WindowsFormsApplication3";bool createdNew;
            Mutex mut = new Mutex(true, appName, out createdNew);if (!createdNew)
            {
                MessageBox.Show($"WindowsFormsApplication3 is already running!", "Multiple Instances");return;
            }
            Application.Run(new Form1());
        }
    }
}
b

 


/template/Home/Zkeys/PC/Static