Click here to Skip to main content
12,697,103 members (26,677 online)
Click here to Skip to main content
Articles » Languages » C# » General » Alternatives
Add your own
alternative version

Tagged as


17 bookmarked

Run Only One Copy Of Application

, 6 Nov 2011 CPOL
Yet another way to this is as follows: using System;using System.Collections.Generic;using System.Windows.Forms;using System.Threading;namespace OnlyOneInstance{ static class Program { [STAThread] static void Main() { bool...


Members may post updates or alternatives to this current article in order to show different approaches or add new features.

13 Apr 2011
How about using a Mutex? This should also work for Terminal Services sessions. Use in Program.csstatic Mutex mut;try{ bool isOwned = false; mut = new Mutex(true, Application.ProductName + " MUTEX: {53A4988C-F91F-4054-9076-220AC5EC03F3}", out isOwned); if (!isOwned)...
25 Mar 2011
Maybe this is helpful, it tries to switch to the first running instance:namespace UltraSimple.Win{ static class Program { [System.Runtime.InteropServices.DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr hWnd); [STAThread] ...
19 Mar 2011
charles henington
5 alternatives  
Run Only One Copy Of Application
30 Mar 2011
Just because we like C# doesn't mean we can't borrow from other .NET languages. I've always had good luck and less complication using VB's single instance methodology in my C# applications. This code would go in your program.cs file:/// /// We inherit from...
29 Mar 2011
Neil A. Harding
I actually use code like this, which allows me to detect a existing instance and to call the original instance with the command line (I expand any filenames present so that it can access the filenames even if the original path is different).string processName =...


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


About the Author

Ravi Ranjan Kr
Software Developer
India India
Microsoft Student Partner | CS Student | MCTS | CP MVP | Crazy Learner | Dreamer

An Indian, who loves his country, believes in freedom, He is an enthusiast Techie and crazy learner. He is passionate about Technologies and social media. He holds bachelor degree of CS in Information Technology and now pursuing Master degree in Computer Application.

He always excited and keen Interested in learning and sharing knowledge. He loves to write blog, learn new things, listen music, taking arts and Playing Games..

He keep himself on the desk of his imagination, hanging around with some inceptions.

| | Privacy | Terms of Use | Mobile
Web01 | 2.8.170118.1 | Last Updated 6 Nov 2011
Article Copyright 2011 by Ravi Ranjan Kr
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid