private void RunProcess() { while (!_stopProcess) { if (this.Status == FactoryProcessStatus.Stopping) { this._stopProcess = true; this.Status = FactoryProcessStatus.Stopped; } else if (this.Status == FactoryProcessStatus.Starting) { this.Status = FactoryProcessStatus.Running; this._stopProcess = false; } else if (this.Status == FactoryProcessStatus.Pausing) { this.Status = FactoryProcessStatus.Paused; this._stopProcess = false; if (OnProcessPaused != null) { OnProcessPaused(); } } else if (this.Status == FactoryProcessStatus.Resuming) { this.Status = FactoryProcessStatus.Running; this._stopProcess = false; } if (this.Status == FactoryProcessStatus.Running) { if (this.OnTimeoutReached != null) { this.OnTimeoutReached(); } } if (this.Status == FactoryProcessStatus.Running || this.Status == FactoryProcessStatus.Paused) { Thread.Sleep(this.Timeout); } } }
public void Stop() { this.Status = FactoryProcessStatus.Stopping; }
public void Start() { this.Status = FactoryProcessStatus.Starting; this.RunProcessAsync(); }
public void Resume() { this.Status = FactoryProcessStatus.Resuming; }
public void Pause() { this.Status = FactoryProcessStatus.Pausing; }
void Factory_OnStatusChanged(FactoryProcessStatus status) { Console.WriteLine("Status changed to: {0}", status); }