zoukankan      html  css  js  c++  java
  • C# 禁止程序多个实例运行

    //program.cs
        static class Program
        {
            /// <summary>
            /// 应用程序的主入口点。
            /// </summary>
            [STAThread]
            static void Main()
            {
                bool ret = false;
                System.Threading.Mutex running = new System.Threading.Mutex(true, Application.ProductName, out ret);
                if (ret)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new FormMain());
                    running.ReleaseMutex();
                }
                else
                {
                    MessageBox.Show("程序已经在运行,请不要同时运行多个本程序!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Application.Exit();
                }
            }
        }

  • 相关阅读:
    什么是Java
    程序有问题解决方法
    面向对象三大特征
    实例变量和局部变量
    内存管理
    常见面试题(更新中)
    多态
    设计规则
    内部类
    编程英语
  • 原文地址:https://www.cnblogs.com/teyond/p/3325583.html
Copyright © 2011-2022 走看看