Tags: application, current, instance, microsoft, msdn, page, runthe, software, splash, visual

Allow only one instance of an application

On Microsoft » Microsoft Visual C#

1,073 words with 3 Comments; publish: Wed, 26 Dec 2007 10:50:00 GMT; (30062.50, « »)

Is there a way to only allow one instance of an application to run?

The current application is rather large and it takes a moment for the splash page to show. I would like to ignore all attempts to open the application while its loading so that only one instance can be running at a time.

All Comments

Leave a comment...

    • you can get the list of processes which are of the same processname perhaps, if there is more than 1 (1 being current process) found then notify them and exit the app:

      Process[] theProcesses = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);

      if (theProcesses.Length > 1)


      MessageBox.Show("More than 1 instance running");



      I'm sure there are other ways as well but hope this gets you started

      #1; Tue, 04 Sep 2007 09:58:00 GMT
    • Worked like a champ!


      #2; Tue, 04 Sep 2007 09:59:00 GMT
    • excellent, glad I could help. Actually edited the post an hour later to make it better, no idea what I was thinking of in the first post but glad that its working for you - the "new and improved" approach at least
      #3; Tue, 04 Sep 2007 10:00:00 GMT