Just one little code snippet for bookmarking. This is snipper for console application. With Windows app you could use Application.Exit(). I could do some machine process name comparing, but that’s gives me only current user processes.
static void Main()
{
Mutex instanceLock = new Mutex(false, "My.Unique.Name.What.Should.Be.Quid");
if (instanceLock.WaitOne(0, false))
{
try
{
var listener = new Listener();
listener.Start();
}
finally
{
instanceLock.ReleaseMutex();
}
}
else
{
Environment.Exit(5);
}
}
And this is my first wordpress post (in their editor, because my live writer is one big wuss). Congratulations to me!
Advertisement