public override void SetResult(T result, bool isCompleted = true) { if (isCompleted) { block?.Dispose(); } base.SetResult(result, isCompleted); }
/// <summary> /// 重置状态 /// </summary> public void Reset() { _locker.EnterWriteLock(); _isValueCreated = false; _block.Dispose(); _value = default(T); _locker.ExitWriteLock(); }
private void timeoutCallback(object state) { if (!IsCompleted) { try { _onTimeoutCallback?.Invoke(this, EventArgs.Empty); } catch (Exception) { } finally { block.Stop(); block.Dispose(); if (_whenTimeoutThrowException) { base.SetError(new TimeoutException()); } else { IsCompleted = true; } } } }