Exemple #1
0
 private void HandleServiceControlCommand(ServiceControlCommand command, uint eventType, IntPtr eventData, IntPtr eventContext)
 {
     try
     {
         _stateMachine.OnCommand(command, eventType);
     }
     catch
     {
         ReportServiceStatus(ServiceState.Stopped, ServiceAcceptedControlCommandsFlags.None, win32ExitCode: -1, waitHint: 0);
     }
 }
Exemple #2
0
        public void ItCanStopServicesWhenRequestedByOS()
        {
            // Given
            doNotBlockAfterServiceMainFunction = true;
            GivenTheServiceHasBeenStarted();

            // When
            WhenTheOSSendsControlCommand(ServiceControlCommand.Stop, commandSpecificEventType: 0);

            // Then
            A.CallTo(() => serviceStateMachine.OnCommand(ServiceControlCommand.Stop, 0)).MustHaveHappened();
        }