参考这篇文章:
运行是检查有是否已经运行的实例,没有运行,有则显示.
http://www.c-sharpcorner.com/FAQ/Create1InstanceAppSC.asp

解决方案 »

  1.   

    [STAThread]
    static void Main() 
    {
    System.Threading.Mutex mutexMyapplication = new System.Threading.Mutex(false, "Form1");
    if(!mutexMyapplication .WaitOne(100, false))
          {
    MessageBox.Show("本程序已经在运行!","提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
    Application.Exit();
    return;
           }
           Application.Run(new Form1());
    }
      

  2.   

    声明:本帖子只供参考,对使用本帖子而引起的任何预想不到的后果作者盖不负责!!
    ⒈判断进程法:
    Process current = Process.GetCurrentProcess(); 
    Process[] processes = Process.GetProcessesByName (current.ProcessName); 
    foreach (Process process in processes) 
    {  
    if (process.Id != current.Id) 

    if ( process.MainModule.FileName
    == current.MainModule.FileName) 

    MessageBox.Show("程序已经运行!",Application.ProductName,
    MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
    return ; 



    ⒉创建互斥体法:
    bool blnIsRunning;
    Mutex mutexApp = new Mutex(false,Assembly.GetExecutingAssembly().FullName,out blnIsRunning);
    if(!blnIsRunning)
    {
    MessageBox.Show("程序已经运行!",Application.ProductName,
    MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
    return ; 
    }
    以上代码仅供参考!