/// <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(); }
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(); }
public void Resume() { if (!this.Enabled || this.state == RadServiceState.Working || this.state != RadServiceState.Paused) { return; } this.state = RadServiceState.Working; this.PerformResume(); }
public void Pause() { if (!this.Enabled || this.state != RadServiceState.Working) { return; } this.state = RadServiceState.Paused; this.PerformPause(); }
/// <summary> /// Resumes previously paused operation. /// </summary> public void Resume() { //may not resume if disabled or currently working if (!this.Enabled || this.state == RadServiceState.Working) { return; } if (this.state == RadServiceState.Paused) { this.state = RadServiceState.Working; this.PerformResume(); } }
/// <summary> /// Pauses a currently running operation. /// </summary> public void Pause() { //may not pause if not enabled if (!this.Enabled) { return; } if (this.state == RadServiceState.Working) { this.state = RadServiceState.Paused; this.PerformPause(); } }
public void Start(object context) { if (!this.CanStart(context)) { return; } RadServiceStartingEventArgs e = new RadServiceStartingEventArgs(context); this.OnStarting(e); if (e.Cancel) { return; } this.SetContext(context); this.state = RadServiceState.Working; this.PerformStart(); this.OnStarted(); }
MessagePreviewResult IMessageListener.PreviewMessage(ref Message msg) { RadServiceState state = this.State; if (state == RadServiceState.Stopped || state == RadServiceState.Initial) { RadMessageFilter.Instance.RemoveListener(this); this.messageFilterAdded = false; return(MessagePreviewResult.NotProcessed); } int message = msg.Msg; switch (message) { case NativeMethods.WM_MOUSEMOVE: case NativeMethods.WM_MOVING: Point mousePos = Control.MousePosition; if (mousePos != this.beginPoint.Value) { this.HandleMouseMove(mousePos); } return(MessagePreviewResult.ProcessedNoDispatch); case NativeMethods.WM_NCLBUTTONUP: case NativeMethods.WM_LBUTTONUP: MessagePreviewResult result = this.initialized ? MessagePreviewResult.ProcessedNoDispatch : MessagePreviewResult.Processed; this.Stop(this.doCommit); return(result); case NativeMethods.WM_KEYDOWN: case NativeMethods.WM_SYSKEYDOWN: if ((Keys)msg.WParam.ToInt32() == Keys.Escape) { this.Stop(false); return(MessagePreviewResult.ProcessedNoDispatch); } break; } return(MessagePreviewResult.Processed); }
protected RadService() { this.state = RadServiceState.Initial; this.enabled = true; }