How to create single instance Windows application
Write the following code under Program.cs
[STAThread]
static void Main()
{
bool IsRunning = true;
using (Mutex mutex = new Mutex(true, “diBook”, out IsRunning))
{
if (IsRunning)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmBooks());
}
}
}
[STAThread]
static void Main()
{
bool IsRunning = true;
using (Mutex mutex = new Mutex(true, “diBook”, out IsRunning))
{
if (IsRunning)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmBooks());
}
}
}