zoukankan      html  css  js  c++  java
  • C#启动单个实例


              Boolean createdNew; //返回是否赋予了使用线程的互斥体初始所属权
                System.Threading.Mutex instance = new System.Threading.Mutex(true, "MutexName", out createdNew); //同步基元变量
                if (createdNew) //赋予了线程初始所属权,也就是首次使用互斥体
                {
                    Application.Run(new Form1()); /s/这句是系统自动写的
                    instance.ReleaseMutex();
                }
                else
                {
                    MessageBox.Show("已经启动了一个程序,请先退出!","系统提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    Application.Exit();
                }
  • 相关阅读:
    PHP之目录遍历
    PHP之验证码
    PHP之验证码
    PHP之异常处理模式
    PHP之pdo的预处理模式
    PHP之PDO
    PHP之cookie和session
    PHP之MVC
    单例模式
    ThreadLocal
  • 原文地址:https://www.cnblogs.com/chenlhuaf/p/1122557.html
Copyright © 2011-2022 走看看