File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,12 @@ static void Main(string[] args)
1515 {
1616 try
1717 {
18- bool instanceCount = false ;
19- Mutex mutex = null ;
18+ int semaphoreCount = 5 ;
19+ Semaphore semaphore = new Semaphore ( semaphoreCount , semaphoreCount , AppDomain . CurrentDomain . FriendlyName ) ;
2020 var projAppName = AppDomain . CurrentDomain . FriendlyName ;
2121 AppDomain . CurrentDomain . ProcessExit += new EventHandler ( OnAppExit ) ;
2222
23- mutex = new Mutex ( true , projAppName , out instanceCount ) ;
24- if ( instanceCount )
23+ if ( semaphore . WaitOne ( TimeSpan . Zero , true ) )
2524 {
2625 if ( args . Length > 0 )
2726 {
@@ -32,16 +31,16 @@ static void Main(string[] args)
3231 Application . EnableVisualStyles ( ) ;
3332 Application . SetCompatibleTextRenderingDefault ( false ) ;
3433 Application . Run ( new QVMEditorForm ( ) ) ;
35- mutex . ReleaseMutex ( ) ;
34+ semaphore . Release ( ) ;
3635 }
3736 else
3837 {
39- QUtils . ShowError ( " QVM Editor is already running ") ;
38+ QUtils . ShowError ( $ "Only { semaphoreCount } instances of QVM Editor are allowed to run at the same time. ") ;
4039 }
4140 }
42- catch ( Exception ex )
41+ catch ( Exception exception )
4342 {
44- QUtils . ShowLogException ( "QVMEditor" , ex ) ;
43+ QUtils . ShowLogException ( "QVMEditor Main Exception: " , exception ) ;
4544 }
4645 }
4746
@@ -55,4 +54,4 @@ private static void OnAppExit(object sender, EventArgs e)
5554 }
5655 }
5756 }
58- }
57+ }
You can’t perform that action at this time.
0 commit comments