Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

Go to top

Run only one instance from you program

, 24 Sep 2010
Rate this:
Please Sign up or sign in to vote.
Use this function in Program.Main()private static bool IsAlreadyRunning(){ //Find name of current process string currentProcessName = Process.GetCurrentProcess().ProcessName; //Find the name of all processes having current process name Process[]...
Use this function in Program.Main()
 
private static bool IsAlreadyRunning()
{
    //Find name of current process
    string currentProcessName = Process.GetCurrentProcess().ProcessName;
    //Find the name of all processes having current process name
    Process[] processesNamesCollection = Process.GetProcessesByName(currentProcessName);
    //Check whether more than one process is running
    if (processesNamesCollection.Length > 1)
       return true;
    else
       return false;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

nCodeIT
Software Developer Indra Italia s.p.a
Italy Italy
No Biography provided
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 5 PinmemberTychoBarfy18-Apr-13 16:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 24 Sep 2010
Article Copyright 2010 by nCodeIT
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid