/// <summary> /// Notifies that a start request has occured. Cancelable. /// </summary> /// <param name="e"></param> protected virtual void OnStarting(StateServiceStartingEventArgs e) { StateServiceStartingEventHandler eh = this.Events[StartingEventKey] as StateServiceStartingEventHandler; if (eh != null) { eh(this, e); } }
/// <summary> /// Starts the Service. /// If the service was previously paused, it should be re-started with the Resume method. /// </summary> public void Start(object context) { //check whether we may start the service if (!this.CanStart(context)) { return; } StateServiceStartingEventArgs e = new StateServiceStartingEventArgs(context); this.OnStarting(e); if (e.Cancel) { return; } this.SetContext(context); this.state = ServiceState.Working; this.PerformStart(); this.OnStarted(); }