Commit graph

11 commits

Author SHA1 Message Date
Jaex b6e25d7e07 Few ApplicationInstanceManager changes 2016-03-18 02:10:56 +02:00
Jaex f23202d7ff Single instance code moved to ApplicationInstanceManager class 2016-03-17 11:03:08 +02:00
Brian 29e8e739e3 Proper Single Instance Implementation
Reworked single instance code to better handle being launched with
context menu.

Previously:
- On launch, process would try to open an `EventWaitHandle`. If it
didn't exist, then process assumed it was first and created it
- Multiple processes launching at same time would all see the
`EventWaitHandle` did not exist before any process could create it
- This led to multiple instances of program running

Now a mutex is used:
- Processes will all try to open the mutex. Only first one will succeed
- Process that opens the mutex will setup the `EventWaitHandle`
- Other processes won't get the mutex and will be directed to use the
`EventWaitHandle` to pass their command line args to the running
instance
2016-03-10 16:29:01 -05:00
Brian d81558291e 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.
2016-03-04 08:45:03 -05:00
Brian c21036aa0e Handle multiple context menu selections - Fixes #770
The problem is that multiple context menu selections spawn multiple .exe
(invoked). Each invoked .exe sets the InstanceProxy variables in the
running .exe and tells it to start a thread to process. But, there is no
waiting, so the InstanceProxy variables get clobbered before they can
get used.
This fix uses a semaphore to control the invoked .exe. There is only one
entry allowed forcing invoked .exe to wait until any other invoked .exe
is finished running and releases the semaphore.
2016-03-03 18:57:21 -05:00
Jaex 1d0842d031 Updated license year to 2016 2016-01-03 17:16:01 +02:00
Jaex 251849aeda Copyright text update 2015-08-13 04:07:38 +03:00
Jaex 65dd658913 Translation changes for about form 2014-12-31 12:07:19 +02:00
Jaex e770e8600f Changing copyright icon 2014-12-31 11:41:32 +02:00
Jaex 9388ebb418 Updated year 2014-12-31 11:29:40 +02:00
Jaex 5096a895f1 Changed project namings (Example: HelpersLib -> ShareX.HelpersLib) 2014-12-10 22:11:55 +02:00
Renamed from HelpersLib/SingleInstanceApplication/ApplicationInstanceManager.cs (Browse further)