Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 0072c84

Browse files
committed
Address PR feedback
1 parent b522f49 commit 0072c84

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public CancellationTokenSource(int millisecondsDelay)
205205
private void InitializeWithTimer(int millisecondsDelay)
206206
{
207207
_state = NotCanceledState;
208-
_timer = Timer.UnsafeCreate(s_timerCallback, this, millisecondsDelay, -1);
208+
_timer = new Timer(s_timerCallback, this, millisecondsDelay, -1, flowExecutionContext: false);
209209
}
210210

211211
/// <summary>Communicates a request for cancellation.</summary>
@@ -345,7 +345,7 @@ public void CancelAfter(int millisecondsDelay)
345345
// Initially set to "never go off" because we don't want to take a
346346
// chance on a timer "losing" the initialization and then
347347
// cancelling the token before it (the timer) can be disposed.
348-
Timer newTimer = Timer.UnsafeCreate(s_timerCallback, this, -1, -1);
348+
Timer newTimer = new Timer(s_timerCallback, this, -1, -1, flowExecutionContext: false);
349349
if (Interlocked.CompareExchange(ref _timer, newTimer, null) != null)
350350
{
351351
// We did not initialize the timer. Dispose the new timer.

src/System.Private.CoreLib/src/System/Threading/Timer.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -685,11 +685,11 @@ public Timer(TimerCallback callback,
685685
{
686686
}
687687

688-
private Timer(TimerCallback callback,
689-
object state,
690-
int dueTime,
691-
int period,
692-
bool flowExecutionContext)
688+
internal Timer(TimerCallback callback,
689+
object state,
690+
int dueTime,
691+
int period,
692+
bool flowExecutionContext)
693693
{
694694
if (dueTime < -1)
695695
throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
@@ -699,10 +699,6 @@ private Timer(TimerCallback callback,
699699
TimerSetup(callback, state, (uint)dueTime, (uint)period, flowExecutionContext);
700700
}
701701

702-
// TODO https://github.com/dotnet/corefx/issues/26523: Consider making public.
703-
internal static Timer UnsafeCreate(TimerCallback callback, object state, int dueTime, int period) =>
704-
new Timer(callback, state, dueTime, period, flowExecutionContext: false);
705-
706702
public Timer(TimerCallback callback,
707703
object state,
708704
TimeSpan dueTime,

0 commit comments

Comments
 (0)