Hi,
I create one exe using windows application file for convert image,
suppose one more exe going to start mean automatically we won't allow
thorw error message the process already processed.
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.
Sam HobbsPosted Apr 9, 2012, 11:38 AM
Your project has a Program.cs file that has a "Main" method. Open (look at) that file. In it there is a line like:
Application.Run(new Form1());
Add the following lines in the Main method before that line:
{}Then after the "Application.Run(new Form1())" add the following:
GC.KeepAlive(InstanceMutex);
Also be sure to add a "using System.Threading;" at the beginning of the Program.cs file.
Keyur NarkhiPosted Apr 9, 2012, 6:32 AM
you can use something like that
Process[] notepads = System.Diagnostics.Process.GetProcessesByName("notepad");
int notepadCount = notepads.Length;
Use your exe name if you get count greater than 0 means the process is running
Thanks
brunda kPosted Apr 9, 2012, 6:29 AM
In above url , they have suggested ways to acheive it.
if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
AppLog.Write("Application XXXX already running. Only one instance of this application is allowed", AppLog.LogMessageType.Warn);
return;
}