Handle multiple context menu selections - Move semaphore release

Current process is as follows:
1. Invoked .exe gets the semaphore
2. Invoked .exe sets `InstanceProxy` values in running exe
3. Invoked .exe causes thread to spawn in running exe
4. New thread in running .exe reads values from `InstanceProxy`
4. Invoked .exe release the semaphore

The problem is that there is no guarantee on how fast new threads in
running .exe will spawn and read values from `InstanceProxy`. This PR
addresses that by moving the semaphore release from the invoked .exe to
the thread spawned in running .exe.
This commit is contained in:
Brian 2016-03-04 08:45:03 -05:00
parent 749ac051ad
commit d81558291e

View file

@ -54,8 +54,6 @@ public static bool CreateSingleInstance(string name, EventHandler<InstanceCallba
UpdateRemoteObject(name);
if (eventWaitHandle != null) eventWaitHandle.Set();
semaphore.Release();
}
Environment.Exit(0);
@ -125,6 +123,8 @@ private static void WaitOrTimerCallback(object state, bool timedOut)
if (callback == null) return;
callback(state, new InstanceCallbackEventArgs(InstanceProxy.IsFirstInstance, InstanceProxy.CommandLineArgs));
semaphore.Release();
}
}
}