mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
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:
parent
749ac051ad
commit
d81558291e
1 changed files with 2 additions and 2 deletions
|
@ -54,8 +54,6 @@ public static bool CreateSingleInstance(string name, EventHandler<InstanceCallba
|
||||||
UpdateRemoteObject(name);
|
UpdateRemoteObject(name);
|
||||||
|
|
||||||
if (eventWaitHandle != null) eventWaitHandle.Set();
|
if (eventWaitHandle != null) eventWaitHandle.Set();
|
||||||
|
|
||||||
semaphore.Release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
|
@ -125,6 +123,8 @@ private static void WaitOrTimerCallback(object state, bool timedOut)
|
||||||
if (callback == null) return;
|
if (callback == null) return;
|
||||||
|
|
||||||
callback(state, new InstanceCallbackEventArgs(InstanceProxy.IsFirstInstance, InstanceProxy.CommandLineArgs));
|
callback(state, new InstanceCallbackEventArgs(InstanceProxy.IsFirstInstance, InstanceProxy.CommandLineArgs));
|
||||||
|
|
||||||
|
semaphore.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue