public void Stop(bool commit) { if (this.state != RadServiceState.Paused && this.state != RadServiceState.Working) { return; } RadServiceStoppingEventArgs e = new RadServiceStoppingEventArgs(commit); this.OnStopping(e); if (e.Cancel) { return; } this.state = RadServiceState.Stopped; if (e.Commit) { this.Commit(); } else { this.Abort(); } this.PerformStop(); this.SetContext((object)null); this.OnStopped(); }
/// <summary> /// Stops currently working or previously stopped service. /// </summary> /// <param name="commit">True to indicate that current operation ended successfully, false otherwise.</param> public void Stop(bool commit) { //the service is not started, do nothing if (!(this.state == RadServiceState.Paused || this.state == RadServiceState.Working)) { return; } RadServiceStoppingEventArgs e = new RadServiceStoppingEventArgs(commit); this.OnStopping(e); if (e.Cancel) { return; } this.state = RadServiceState.Stopped; //use the Commit member of the event arguments as the user may have changed it. if (e.Commit) { this.Commit(); } else { this.Abort(); } this.PerformStop(); this.SetContext(null); this.OnStopped(); }
/// <summary> /// Notifies that a stop request has occured. Cancelable. /// </summary> /// <param name="e"></param> protected virtual void OnStopping(RadServiceStoppingEventArgs e) { EventHandler <RadServiceStoppingEventArgs> eh = this.Events[StoppingEventKey] as EventHandler <RadServiceStoppingEventArgs>; if (eh != null) { eh(this, e); } }
protected virtual void OnStopping(RadServiceStoppingEventArgs e) { EventHandler <RadServiceStoppingEventArgs> eventHandler = this.Events[RadService.StoppingEventKey] as EventHandler <RadServiceStoppingEventArgs>; if (eventHandler == null) { return; } eventHandler((object)this, e); }