By using Mutex
the object you can prevent users from running more than one instance of the application. Check out this code snippet
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace SingleInstacle
{
public class Program
{
static void Main(string[] args)
{
bool createdNew = false;
Mutex mutex = new Mutex(true, "SingleInstance", out createdNew);
if (createdNew)
{
Console.WriteLine("Hello world");
}
else
{
Console.WriteLine("You can only run a single instance of this app!");
}
Console.ReadLine();
}
}
}