让程序只运行一个实例的方法

using System.Threading;

public class Class1
{
    [STAThread]
    
static void Main()
    
{
        Mutex mutex 
= new Mutex(false"MutexName");
        
if (!mutex.WaitOne(0false))
        
{
            mutex.Close();
            MessageBox.Show(
"Another instance is aready running!");
            
return;
        }


        Application.Run(
new Form1());
    }

}

posted @   泡面 @ 幸福  阅读(317)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示