public void CheckTimeOut(string reason = "") { this.Start(); DateTime now = DateTime.Now; this.totalElapsed += now - this.start; this.start = now; if (this.totalElapsed.TotalSeconds < (double) this.timeout) return; if (this.exception == null) this.exception = new TimeoutExceptionFixpointComputation(); throw this.exception; }
public TimeOutChecker(int seconds, bool start = true) { this.totalElapsed = new TimeSpan(); if (start) { this.start = DateTime.Now; this.state = TimeOutChecker.State.Running; } else this.state = TimeOutChecker.State.Stopped; this.timeout = seconds; this.exception = (TimeoutExceptionFixpointComputation) null; }