I have an application that I want to Hide instead of closing in order to run in the background. If I hide it, when I relaunch the application, how do I kill the new instance while Unhiding/reactivate the currently running application? I can terminate the current instance with;
string currPrsName = Process.GetCurrentProcess().ProcessName;
//Get the name of all processes having the same name as this process name
Process[] theProcessWithThisName = Process.GetProcessesByName(currPrsName);
if (theProcessWithThisName.Length > 1)
{
string message = "'" + currPrsName + ".exe'" + " is already running.\nOperation canceled";
string caption = "ALREADY RUNNING";
MessageBox.Show(message, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
Environment.Exit(0); //Terminate this instance
}
I have tried various ways to unhide the app with no success.