Reputation: 1287
How can I use mutex to find first process by GUID and call function in it ? Like in web browser when you try to start it second time it just open a new window.
// appGuid is const string containing app GUID
using (Mutex mutex = new Mutex(false, "Global\\" + appGuid))
{
if (!mutex.WaitOne(0, false))
{
// CODE TO FIND AND CALL FIRST PROCESS AND THEN EXIT
Environment.Exit(0);
}
else
{
App app = new App();
app.InitializeComponent();
app.Run();
}
}
Upvotes: 0
Views: 91
Reputation: 8872
I think there are a lot of ways to tackle the "oh you opened a second instance, but we only allow one, so lets proxy your request to the first instance" problem.
That's 3 ideas, there are probably more
But, if you just want to get process information why not just look up the process by name?
Upvotes: 1