C#: Create a single instance application
Under certain circumstances you may want to allow only one instance of your applications. How do I do that in C#? Well, it is fairly easy. Start by creating a Windows Forms Application.
Include the following Namespace:
using System.Runtime.InteropServices;
Just wrap the following code around the Application.Run() call and there you go:
Process[] runningProcesses = Process.GetProcessesByName("Project1");
if (runningProcesses.Length == 1)
{
Application.Run(new Form1());
}



