Maybe this is helpful, it tries to switch to the first running instance:
namespace UltraSimple.Win
{
static class Program
{
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[STAThread]
static void Main()
{
Process oProcess = Process.GetCurrentProcess();
Process[] aoProcesses = Process.GetProcessesByName(oProcess.ProcessName);
if (aoProcesses.Length > 1)
{
MessageBox.Show(
"The application \""
+ oProcess.ProcessName
+ "\" is already running.", "Ultrasimple");
Program.SetForegroundWindow(aoProcesses[aoProcesses[0].Id ==
oProcess.Id ? 1 : 0].MainWindowHandle);
return;
}
...
}
}
}