I have a c#/WPF application that on some clients sites runs over RPD i.e. the application resides on the clients server and users access through terminal services sessions.
The problem I'm having is that I can't prevent multiple instances of the application opening accidently. When the application is running locally on a machine I can block out multiple instances using the following:
var processName = Process.GetCurrentProcess().ProcessName;
if (Process.GetProcesses().Count(p => p.ProcessName.Equals(processName)) > 1)
{
this.Log.LogInfo(this.GetType(), "Process already running. Shutting down.");
Application.Current.Shutdown();
Process.GetCurrentProcess().Kill();
}
However, over RPP this won't work as there may be other instances of the application running on different RDP sessions.
Anybody know how I can disable a second application instance running in the same RDP session?