From 3b4052df0d5f430d06598e45804f9a4ba172146e Mon Sep 17 00:00:00 2001 From: jjasper4 Date: Wed, 28 Jan 2009 21:28:10 +0000 Subject: [PATCH] correct currentState required/test beep on success git-svn-id: https://svn.kenai.com/svn/winsw~subversion/trunk@27 c8b2a3fe-9b5b-6a51-a37e-dc31b0e308fa --- Main.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Main.cs b/Main.cs index 968d374..9854d33 100644 --- a/Main.cs +++ b/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); }