// A timer in our TimerQueue.
[DebuggerDisplay("{DisplayString,nq}")]
[DebuggerTypeProxy(typeof(TimerDebuggerTypeProxy))]
- internal sealed partial class TimerQueueTimer : IThreadPoolWorkItem
+ internal sealed class TimerQueueTimer : IThreadPoolWorkItem
{
// The associated timer queue.
private readonly TimerQueue _associatedTimerQueue;
// after all pending callbacks are complete. We set _canceled to prevent any callbacks that
// are already queued from running. We track the number of callbacks currently executing in
// _callbacksRunning. We set _notifyWhenNoCallbacksRunning only when _callbacksRunning
- // reaches zero. Same applies if Timer.DisposeAsync() is used, except with a Task<bool>
+ // reaches zero. Same applies if Timer.DisposeAsync() is used, except with a Task
// instead of with a provided WaitHandle.
private int _callbacksRunning;
private bool _canceled;
internal bool _everQueued;
- private object? _notifyWhenNoCallbacksRunning; // may be either WaitHandle or Task<bool>
+ private object? _notifyWhenNoCallbacksRunning; // may be either WaitHandle or Task
internal TimerQueueTimer(TimerCallback timerCallback, object? state, uint dueTime, uint period, bool flowExecutionContext)
{
Debug.Assert(
notifyWhenNoCallbacksRunning == null ||
- notifyWhenNoCallbacksRunning is Task<bool>);
+ notifyWhenNoCallbacksRunning is Task);
- // There are callbacks queued or running, so we need to store a Task<bool>
+ // There are callbacks queued or running, so we need to store a Task
// that'll be used to signal the caller when all callbacks complete. Do so as long as
// there wasn't a previous CloseAsync call that did.
if (notifyWhenNoCallbacksRunning == null)
{
- var t = new Task<bool>((object?)null, TaskCreationOptions.RunContinuationsAsynchronously);
+ var t = new Task((object?)null, TaskCreationOptions.RunContinuationsAsynchronously, true);
_notifyWhenNoCallbacksRunning = t;
return new ValueTask(t);
}
// A previous CloseAsync call already hooked up a task. Just return it.
- return new ValueTask((Task<bool>)notifyWhenNoCallbacksRunning);
+ return new ValueTask((Task)notifyWhenNoCallbacksRunning);
}
}
internal void SignalNoCallbacksRunning()
{
object? toSignal = _notifyWhenNoCallbacksRunning;
- Debug.Assert(toSignal is WaitHandle || toSignal is Task<bool>);
+ Debug.Assert(toSignal is WaitHandle || toSignal is Task);
if (toSignal is WaitHandle wh)
{
}
else
{
- ((Task<bool>)toSignal).TrySetResult(true);
+ ((Task)toSignal).TrySetResult();
}
}