This code creates a mutex before starting an application and releases the mutex when the application is closed. A user will only be able to start the application once. This can be used for services as well.
public static void Main()
bool createdMutex = true
Mutex mutex = new Mutex(true, "ConfigureApp", out createdMutex)
if (createdMutex && mutex.WaitOne())
MessageBox.Show("Only one application instance is allowed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Studied Engineering Computer Science at Techinikon Pretoria, South Africa.
Have been a Software Developer for 9 year using different technologies nl. Assembler 8, 16, 32 and 64 bit, Delphi 6 and 7, C++, Java, ASP. For last 7 year I focused on C# and ASP.net also have extensive SQL 2000, 2005 and 2008 experience. I am currently employed as a Software Development Team leader and Software Architect at a vehicle tracking company in South Africa.