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();
                }
            }
        }

  • 相关阅读:
    Gerrit配置--用户配置
    repo+manifests+git方式管理安卓代码
    FLASH OTP
    Wireshark抓包分析TCP协议
    python 批量修改图片大小
    python 文件查找 glob
    python 统计单词个数
    python 图片上添加数字源代码
    python 删除文件和文件夹
    python 程序列表
  • 原文地址:https://www.cnblogs.com/teyond/p/3325583.html
Copyright © 2011-2022 走看看