Introduction
After spending some time studying the C#, I started to develop some components and applications so i thought before i could jump into articles relating to user controls i could contribute this code snippet that retricts the application from creating multiple instances.
The following code uses the System.Diagnostics
namespace to identify the application process name. So you just have to create new windows application project and just replace code in the main function in the form with the code provided below.
static void Main()
Int32 _isProcessRunning;
_isProcessRunning = System.Diagnostics.Process.GetProcessesByName(<BR> System.Diagnostics.Process.GetCurrentProcess().ProcessName).Length;
if(_isProcessRunning != 1)
{
MessageBox.Show("Already an Instance running");
}
else
{
Application.Run(new Form1());
}
Test your application by executing your application exe from the \bin\Debug folder.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.