I deployed my C# WinForms application using ClickOnce installation. Everything works fine with it (after a lot of work) :), but now I'm facing a problem:
Whenever I click on the application shortcut in the Start menu, a new instance starts. I need to avoid this.
What can I do to prevent multiple launches?
At program startup check if same process is already running:
using System.Diagnostics;
static void Main(string[] args)
{
String thisprocessname = Process.GetCurrentProcess().ProcessName;
if (Process.GetProcesses().Count(p => p.ProcessName == thisprocessname) > 1)
return;
}