Hello!
Do you now any way to limit one app to be executed one only time?
Regards
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Juan Antonio 0Posted Nov 17, 2008, 7:06 AM
AlanPosted Nov 14, 2008, 6:52 AM
Try placing the following code as the first lines in your Main() method:
using System;
using System.Diagnostics;
static class Program
{
static void Main(string[] args)
{
Process current = Process.GetCurrentProcess();
Process[] procs = Process.GetProcessesByName(current.ProcessName);
if (procs.Length > 1)
{
// silently kill this instance if another already running
return;
}
// rest of code
}
}