protected override void InternalWaitComplete(ref bool waitComplete, XTimeout tOut) { base.InternalWaitComplete(ref waitComplete, tOut); if (waitComplete && tOut.Keep()) { while (_data.Count > 0 && tOut.Keep()) { Thread.Sleep(100); } } waitComplete = false; _cancellationTokenSource.Cancel(); _cancellationTokenSource = new CancellationTokenSource(); }
public async Task <bool> Stop(TimeSpan?timeout = null, bool waitComplete = false) { var tOut = new XTimeout(timeout ?? TimeSpan.Zero); lock (_syncRunning) { if (!_active || IsStopping) { return(false); } _waitComplete = waitComplete; IsStopping = true; } return(await Task.Run(() => { InternalWaitComplete(ref _waitComplete, tOut); return tOut.WaitOne(_waitStop); })); }
protected virtual void InternalWaitComplete(ref bool waitComplete, XTimeout tOut) { }