@@ -61,7 +61,8 @@ await dispatcher.RunAsync(priority, () =>
6161 public class LibUtils
6262 {
6363 private static readonly ILogger Logger = LibsignalLogging . CreateLogger < LibUtils > ( ) ;
64- public const string GlobalSemaphoreName = "SignalWindowsPrivateMessenger_Mutex" ;
64+ public const string GlobalMutexName = "SignalWindowsPrivateMessenger_Mutex" ;
65+ public const string GlobalEventWaitHandleName = "SignalWindowsPrivateMessenger_EventWaitHandle" ;
6566 public static string URL = "https://textsecure-service.whispersystems.org" ;
6667 public static SignalServiceUrl [ ] ServiceUrls = new SignalServiceUrl [ ] { new SignalServiceUrl ( URL , null ) } ;
6768 public static bool MainPageActive = false ;
@@ -74,7 +75,7 @@ public class LibUtils
7475 internal static void Lock ( )
7576 {
7677 Logger . LogTrace ( "System lock locking, sync context = {0}" , SynchronizationContext . Current ) ;
77- GlobalLock = new Mutex ( false , GlobalSemaphoreName , out bool createdNew ) ;
78+ GlobalLock = new Mutex ( false , GlobalMutexName , out bool createdNew ) ;
7879 GlobalLockContext = SynchronizationContext . Current ;
7980 try
8081 {
@@ -89,7 +90,7 @@ internal static void Lock()
8990
9091 public static bool Lock ( int timeout )
9192 {
92- GlobalLock = new Mutex ( false , GlobalSemaphoreName , out bool createdNew ) ;
93+ GlobalLock = new Mutex ( false , GlobalMutexName , out bool createdNew ) ;
9394 GlobalLockContext = SynchronizationContext . Current ;
9495 Logger . LogTrace ( "System lock locking with timeout, sync context = {0}" , SynchronizationContext . Current ) ;
9596 bool success = false ;
@@ -129,5 +130,23 @@ public static void Unlock()
129130 }
130131 Logger . LogTrace ( "System lock released" ) ;
131132 }
133+
134+ public static EventWaitHandle OpenResetEventSet ( )
135+ {
136+ Logger . LogTrace ( "OpenResetEventSet()" ) ;
137+ var handle = new EventWaitHandle ( true , EventResetMode . ManualReset , GlobalEventWaitHandleName , out bool createdNew ) ;
138+ if ( ! createdNew )
139+ {
140+ Logger . LogTrace ( "OpenResetEventSet() setting old event" ) ;
141+ handle . Set ( ) ;
142+ }
143+ return handle ;
144+ }
145+
146+ public static EventWaitHandle OpenResetEventUnset ( )
147+ {
148+ Logger . LogTrace ( "OpenResetEventUnset()" ) ;
149+ return new EventWaitHandle ( false , EventResetMode . ManualReset , GlobalEventWaitHandleName , out bool createdNew ) ;
150+ }
132151 }
133152}
0 commit comments