private unsafe int ServiceCommandCallbackEx(int command, int eventType, IntPtr eventData, IntPtr eventContext) { int result = WIN32.NO_ERROR; if (!this.HandleCommandCallback(command)) { switch (command) { case WIN32.SERVICE_CONTROL_POWEREVENT: { new DeferredHandlerDelegateAdvanced(this.DeferredPowerEvent).BeginInvoke(eventType, eventData, null, null); return(result); } case WIN32.SERVICE_CONTROL_SESSIONCHANGE: { DeferredHandlerDelegateAdvancedSession session = new DeferredHandlerDelegateAdvancedSession(this.DeferredSessionChange); WIN32.WTSSESSION_NOTIFICATION structure = new WIN32.WTSSESSION_NOTIFICATION(); Marshal.PtrToStructure(eventData, structure); session.BeginInvoke(eventType, structure.sessionId, null, null); return(result); } } // Not a command that we internally process. Allow subclasses a crack at it. try { if (this.ShouldDeferCustomCommandEx(command, eventType, eventData, eventContext)) { new DeferredHandlerDelegateCommandEx(this.DeferredCustomCommandEx).BeginInvoke(command, eventType, eventData, eventContext, null, null); } else { result = this.OnCustomCommandEx(command, eventType, eventData, eventContext); } } catch (Exception exception) { this.WriteEventLogEntry(Res.GetString("CommandFailed", exception.ToString()), EventLogEntryType.Error); throw; } } return(result); }
private unsafe int ServiceCommandCallbackEx(int command, int eventType, IntPtr eventData, IntPtr eventContext) { int result = WIN32.NO_ERROR; if (!this.HandleCommandCallback(command)) { switch (command) { case WIN32.SERVICE_CONTROL_POWEREVENT: { new DeferredHandlerDelegateAdvanced(this.DeferredPowerEvent).BeginInvoke(eventType, eventData, null, null); return result; } case WIN32.SERVICE_CONTROL_SESSIONCHANGE: { DeferredHandlerDelegateAdvancedSession session = new DeferredHandlerDelegateAdvancedSession(this.DeferredSessionChange); WIN32.WTSSESSION_NOTIFICATION structure = new WIN32.WTSSESSION_NOTIFICATION(); Marshal.PtrToStructure(eventData, structure); session.BeginInvoke(eventType, structure.sessionId, null, null); return result; } } // Not a command that we internally process. Allow subclasses a crack at it. try { if (this.ShouldDeferCustomCommandEx(command, eventType, eventData, eventContext)) { new DeferredHandlerDelegateCommandEx(this.DeferredCustomCommandEx).BeginInvoke(command, eventType, eventData, eventContext, null, null); } else { result = this.OnCustomCommandEx(command, eventType, eventData, eventContext); } } catch (Exception exception) { this.WriteEventLogEntry(Res.GetString("CommandFailed", exception.ToString()), EventLogEntryType.Error); throw; } } return result; }