位置:首页 > 编程专栏 > C#

Winform 防止程序重复打开

Winform 防止程序重复打开
using System;
using System.Windows.Forms;
using System.Threading;

namespace Test
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            bool result;
            Application.EnableVisualStyles();
            Mutex m = new Mutex(true, Application.ProductName, out result);
            if (result)
            {
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainFrom());
            }
        }
    }
}

C# 社区推荐