How can I prevent launching my app multiple times?

后端 未结 10 1838
北荒
北荒 2020-12-13 18:42

I deployed my C# WinForms application using ClickOnce installation. Everything works fine with it (after a lot of work) :), but now I\'m facing a problem:

Whenever

10条回答
  •  既然无缘
    2020-12-13 19:08

    what i always using is

    bool checkSingleInstance()
        {
            string procName = Process.GetCurrentProcess().ProcessName;
            // get the list of all processes by that name
    
            Process[] processes = Process.GetProcessesByName(procName);
    
            if (processes.Length > 1)
            {
    
                return true;
            }
            else
            {
                return false;
            }
        }
    

提交回复
热议问题