Skip to content

Commit 876f289

Browse files
committed
Added DispatchAfter specifying DateTime
1 parent 4966062 commit 876f289

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

DispatchQueue/ConcurrentQueue.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,10 @@ public void DispatchAfter(TimeSpan when, object? context, WaitCallback work)
2525
{
2626
mTimerQueue.DispatchAfter(when, context, work);
2727
}
28+
29+
public void DispatchAfter(DateTime when, object? context, WaitCallback work)
30+
{
31+
mTimerQueue.DispatchAfter(when, context, work);
32+
}
2833
}
2934
}

DispatchQueue/IDispatchQueue.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public interface IDispatchQueue
1010
{
1111
public void DispatchAsync(object? context, WaitCallback work);
1212
public void DispatchAfter(TimeSpan when, object? context, WaitCallback work);
13+
public void DispatchAfter(DateTime when, object? context, WaitCallback work);
1314
}
1415

1516

DispatchQueue/SerialQueue.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public void DispatchAfter(TimeSpan when, object? context, WaitCallback work)
8484
mTimerQueue.DispatchAfter(when, context, work);
8585
}
8686

87+
public void DispatchAfter(DateTime when, object? context, WaitCallback work)
88+
{
89+
mTimerQueue.DispatchAfter(when, context, work);
90+
}
91+
8792
#endregion
8893

8994

DispatchQueue/TimerQueue.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public TimerQueue(IDispatchQueue dispatchQueue, IThreadPool threadPool)
7171
#region Public Methods
7272

7373
public void DispatchAfter(TimeSpan when, object? context, WaitCallback work)
74+
{
75+
DispatchAfter(DateTime.Now + when, context, work);
76+
}
77+
78+
public void DispatchAfter(DateTime when, object? context, WaitCallback work)
7479
{
7580
if (work == null)
7681
{
@@ -79,7 +84,7 @@ public void DispatchAfter(TimeSpan when, object? context, WaitCallback work)
7984

8085
TimerQueueData data = new TimerQueueData()
8186
{
82-
TargetTime = DateTime.Now + when,
87+
TargetTime = when,
8388
Work = work,
8489
Context = context
8590
};

0 commit comments

Comments
 (0)