I am developing a WPF application using MVVM Light.
I would like to know how to check and prevent the user from running more than one instance of the application?
Thank you for your help.
Romain
I am developing a WPF application using MVVM Light.
I would like to know how to check and prevent the user from running more than one instance of the application?
Thank you for your help.
Romain
You can check running processes on application startup and exit if copy is already present:
var appProcessName = Process.GetCurrentProcess().ProcessName;
var matchingProcesses = Process.GetProcessesByName(appProcessName);
if (matchingProcesses.Any())
{
// Exit
}
I think what you are looking for is called a single instance mutex. Google has many results, but I used one recently from this thread for a Windows Forms app.