There are different approaches for this. One of this method is use
FindWindow, SetForegroundWindow:
// in the main function
IntPtr nWnd = FindWindow(null, "Main Window Title");
if(nWnd != IntPtr.Zero)
{
SetForegroundWindow(nWnd);
Application.Exit();
}
....
[DllImport("coredll",EntryPoint="FindWindow")]
private static extern IntPtr FindWindow(string className, string
windowName);
[DllImport("coredll",EntryPoint="SetForegroundWindow")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
Best regards,
Sergey Bogdanov