Skip to content

Commit a9337cc

Browse files
committed
Fixed timer in taskscheduler
1 parent 75fe63e commit a9337cc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

TSLib/Scheduler/DedicatedTaskScheduler.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public sealed class DedicatedTaskScheduler : TaskScheduler, IDisposable
3030
// The TimeSpan class is used for calculation convenience
3131
// The values is used as a cache so we don't need to recheck the list on each loop
3232
private TimeSpan nextTimerDue = TimeSpan.MaxValue;
33+
private readonly Stopwatch monotoneClock = Stopwatch.StartNew();
3334
private bool IsOwnThread => Thread.CurrentThread == thread;
3435
#if DEBUG
3536
private readonly Stack<Task> taskStack = new Stack<Task>();
@@ -234,7 +235,7 @@ internal void DisableTimer(TickWorker timer)
234235

235236
internal void BumpTimer() => QueueTaskInternal(Task.CompletedTask);
236237

237-
private TimeSpan GetTimestamp() => new TimeSpan(Stopwatch.GetTimestamp());
238+
private TimeSpan GetTimestamp() => monotoneClock.Elapsed;
238239

239240
public void VerifyOwnThread()
240241
{

0 commit comments

Comments
 (0)