zoukankan      html  css  js  c++  java
  • 系统只运行一次exe进程

    使用线程互斥变量. 通过定义互斥变量来判断是否已运行实例.C#实现如下: 
    把program.cs文件里的Main()函数改为如下代码: 
    static void Main() 
    { 
    bool runone; 
    System.Threading.Mutex run = new System.Threading.Mutex(true, "jiaao_test", out runone); 
    if (runone) 
    { 
    run.ReleaseMutex(); 
    Application.EnableVisualStyles(); 
    Application.SetCompatibleTextRenderingDefault(false); 
    Application.Run(new Form1()); 
    } 
    else 
    { 
    MessageBox.Show("已经运行了一个实例了。"); 
    } 
    }
  • 相关阅读:
    164-268. 丢失的数字
    163-20. 有效的括号
    Sword 30
    Sword 29
    Sword 27
    Sword 25
    Sword 24
    Sword 22
    Sword 21
    Sword 18
  • 原文地址:https://www.cnblogs.com/wangyuanxun/p/2077429.html
Copyright © 2011-2022 走看看