Skip to content

Instantly share code, notes, and snippets.

@SamKr
Last active January 6, 2020 14:02
Show Gist options
  • Save SamKr/e6f7bb1005205c1fbc26eb906e27c948 to your computer and use it in GitHub Desktop.
Save SamKr/e6f7bb1005205c1fbc26eb906e27c948 to your computer and use it in GitHub Desktop.
Checks whether the current exec is already running (user agnostic)
public static bool IsRunning()
{
var proc = Assembly.GetExecutingAssembly().GetName().Name;
var processes = Process.GetProcesses().ToList();
var activeProcs = processes.Where(x => x.ProcessName.ToLower() == proc).ToList();
return activeProcs.Count > 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment