Browse Source

correct currentState required/test beep on success

git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@27 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa
jjasper4 17 years ago
parent
commit
3b4052df0d
1 changed files with 16 additions and 4 deletions
  1. 16 4
      Main.cs

+ 16 - 4
Main.cs

@@ -571,7 +571,7 @@ namespace winsw
 
                 WaitForProcessToExit(process);
                 WaitForProcessToExit(stopProcess);
-//                Console.Beep();
+                Console.Beep();
             }
         }
 
@@ -581,22 +581,34 @@ namespace winsw
 
             try
             {
-                while (process.WaitForExit(3000))
+                while (process.WaitForExit(1000))
                 {
                     SignalShutdownPending();
                 }
             }
-            catch (InvalidOperationException)
+            catch (InvalidOperationException ex)
             {
+                WriteEvent("already terminated", ex);
                 // already terminated
             }
+
+            SignalShutdownComplete();
         }
 
         private void SignalShutdownPending()
         {
             IntPtr handle = this.ServiceHandle;
             wrapperServiceStatus.checkPoint++;
-            wrapperServiceStatus.waitHint = 5000;
+            wrapperServiceStatus.waitHint = 10000;
+            wrapperServiceStatus.currentState = (int)State.SERVICE_STOP_PENDING;
+            SetServiceStatus(handle, ref wrapperServiceStatus);
+        }
+
+        private void SignalShutdownComplete()
+        {
+            IntPtr handle = this.ServiceHandle;
+            wrapperServiceStatus.checkPoint++;
+            wrapperServiceStatus.currentState = (int)State.SERVICE_STOPPED;
             SetServiceStatus(handle, ref wrapperServiceStatus);
         }