Okay, I have this program and I don't want more than one instance of it running. So what I have right now is it grabs all instances that match it's name, and if there are more than one it quits and lets the user know it's already running in another instance.
However, there is a special case in which the new instance will want change what the other instance is doing, then it will exit. How can I do this?
Here's an example: I have this program that times an event. I don't want more than one running at the same time because you can't be doing two things at once (for this application). Now say a third party program wants to notify this thread that the user is now working on something else, so it launches the application again. If the application is already running, it will update it's actions, else it will act as normal.
How can this be done?
This is what I use to tell if there is another instance running:
string proc = Process.GetCurrentProcess().ProcessName;
Process[] processess = Process.GetProcessesByName(proc);
if (processess.Length > 1) {
MessageBox.Show("There is an instance of the Timer already running");
return;
}