Click here to Skip to main content
11,567,814 members (48,380 online)
Click here to Skip to main content

Tagged as

Run only one instance from you program

, 24 Sep 2010 CPOL 2.2K 1
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

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 5 Pin
TychoBarfy18-Apr-13 16:29
memberTychoBarfy18-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 | Terms of Use | Mobile
Web03 | 2.8.150624.2 | Last Updated 24 Sep 2010
Article Copyright 2010 by nCodeIT
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid