Using the process as below
First create a method to get the instance is already running or not as below
using System.Diagnostics;
public static Process PriorProcess()
{
Process curr = Process.GetCurrentProcess();
Process[] procs = Process.GetProcessesByName(curr.ProcessName);
foreach (Process p in procs)
{
if ((p.Id != curr.Id) &&
(p.MainModule.FileName == curr.MainModule.FileName))
return p;
}
return null;
}
Now by using this, you can check at the Main method as
static void Main() // args are OK here, of course
{
if (PriorProcess() != null)
{
MessageBox("Another instance is already running.");
return;
}
Application.Run(new Form1()); // or whatever was here
}
Regarding Mutex usage... if you can do R&D that's great. But if you want me
to post the details here will do that...
HTH and don't forget to rate the post
--
Every thing is perfect, as long as you share!!!
Don''t forget to rate the post
"melon" wrote:
Let's say I have a program.exe file. When I run it, one instance of
it will be created.
If I run it again, then another instance will be created. Question
is, is it possible for instance #2 to issue command to instance #1, or
vice versa?
Thanks