@@ -21,17 +21,12 @@ import (
2121// *WindowsService - Represents Windows service
2222type * WindowsService struct {
2323 command ServiceCommand
24-
25- onStopDelegate func ()
26- onStopDelegateSync * sync.RWMutex
2724}
2825
2926// New -
3027func New (command ServiceCommand ) SystemService {
3128 return & * WindowsService {
32- command : command ,
33- onStopDelegate : nil ,
34- onStopDelegateSync : & sync.RWMutex {},
29+ command : command ,
3530 }
3631}
3732
@@ -222,16 +217,12 @@ func (thisRef *WindowsService) Restart() error {
222217}
223218
224219// Stop -
225- func (thisRef * * WindowsService ) Stop (onStopDelegate func () ) error {
220+ func (thisRef * * WindowsService ) Stop () error {
226221 logging .Instance ().LogDebugWithFields (loggingC.Fields {
227222 "method" : helpersReflect .GetThisFuncName (),
228223 "message" : fmt .Sprint ("attempting to stop: " , thisRef .command .Name ),
229224 })
230225
231- thisRef .onStopDelegateSync .Lock ()
232- thisRef .onStopDelegate = onStopDelegate
233- thisRef .onStopDelegateSync .Unlock ()
234-
235226 err := thisRef .control (svc .Stop , svc .Stopped )
236227 if err != nil {
237228 e := err .Error ()
@@ -404,11 +395,9 @@ loop:
404395
405396 case svc .Stop , svc .Shutdown :
406397
407- thisRef .onStopDelegateSync .Lock ()
408- defer thisRef .onStopDelegateSync .Unlock ()
409- if thisRef .onStopDelegate != nil {
410- thisRef .onStopDelegate ()
411- thisRef .onStopDelegate = nil
398+ if thisRef .command .OnStopDelegate != nil {
399+ thisRef .command .OnStopDelegate ()
400+ thisRef .command .OnStopDelegate = nil
412401 }
413402
414403 // golang.org/x/sys/windows/svc.TestExample is verifying this output.
0 commit comments