I use this snippet to detect if an instance of my application is already running.
public static Process RunningInstance()
{
Process current = Process.GetCurrentProcess();
Process[] processes = Process.GetProcessesByName (current.ProcessName);
foreach (Process process in processes)
{
if (process.Id != current.Id)
{
if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
{
return process;
}
}
}
return null;
}
However, I was thinking, is there a way to parse send the arguments in the current process to the already running process. Like in an app that adds files, I would like to kill the new process but send it's arguments to the already running process.