Skip to content

Commit c7b4036

Browse files
afifi-insmconnew
authored andcommitted
replace TimeSpan.FromMilliseconds(-1) with Timeout.InfiniteTimeSpan
1 parent af275d1 commit c7b4036

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

src/System.ServiceModel.NetFramingBase/src/System/ServiceModel/Channels/IdlingCommunicationPool.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ private void CancelTimer()
165165
{
166166
if (_idleTimer != null)
167167
{
168-
_idleTimer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
168+
_idleTimer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
169169
}
170170
}
171171

@@ -180,11 +180,11 @@ private void StartTimerIfNecessary()
180180
s_onIdle = new Action<object>(OnIdle);
181181
}
182182

183-
_idleTimer = new Timer(new TimerCallback(new Action<object>(s_onIdle)), this, _idleTimeout, TimeSpan.FromMilliseconds(-1));
183+
_idleTimer = new Timer(new TimerCallback(new Action<object>(s_onIdle)), this, _idleTimeout, Timeout.InfiniteTimeSpan);
184184
}
185185
else
186186
{
187-
_idleTimer.Change(_idleTimeout, TimeSpan.FromMilliseconds(-1));
187+
_idleTimer.Change(_idleTimeout, Timeout.InfiniteTimeSpan);
188188
}
189189
}
190190
}
@@ -267,7 +267,7 @@ public void Prune(List<TItem> itemsToClose, bool calledFromTimer)
267267

268268
if (calledFromTimer && setTimer)
269269
{
270-
_idleTimer.Change(_idleTimeout, TimeSpan.FromMilliseconds(-1));
270+
_idleTimer.Change(_idleTimeout, Timeout.InfiniteTimeSpan);
271271
}
272272
}
273273

src/System.ServiceModel.Primitives/src/Internals/System/Runtime/InputQueue.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ public AsyncQueueReader(InputQueue<T> inputQueue, TimeSpan timeout, AsyncCallbac
907907
_inputQueue = inputQueue;
908908
if (timeout != TimeSpan.MaxValue)
909909
{
910-
_timer = new Timer(new TimerCallback(s_timerCallback), this, timeout, TimeSpan.FromMilliseconds(-1));
910+
_timer = new Timer(new TimerCallback(s_timerCallback), this, timeout, Timeout.InfiniteTimeSpan);
911911
}
912912
}
913913

@@ -932,7 +932,7 @@ public void Set(Item item)
932932
_item = item.Value;
933933
if (_timer != null)
934934
{
935-
_timer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
935+
_timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
936936
}
937937
Complete(false, item.Exception);
938938
}
@@ -958,7 +958,7 @@ public AsyncQueueWaiter(TimeSpan timeout, AsyncCallback callback, object state)
958958
{
959959
if (timeout != TimeSpan.MaxValue)
960960
{
961-
_timer = new Timer(new TimerCallback(s_timerCallback), this, timeout, TimeSpan.FromMilliseconds(-1));
961+
_timer = new Timer(new TimerCallback(s_timerCallback), this, timeout, Timeout.InfiniteTimeSpan);
962962
}
963963
}
964964

@@ -976,7 +976,7 @@ public void Set(bool itemAvailable)
976976

977977
lock (ThisLock)
978978
{
979-
timely = (_timer == null) || _timer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
979+
timely = (_timer == null) || _timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
980980
_itemAvailable = itemAvailable;
981981
}
982982

src/System.ServiceModel.Primitives/src/System/ServiceModel/Channels/ServiceChannel.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2339,7 +2339,7 @@ internal AsyncWaiter(CallOnceManager manager, TimeSpan timeout,
23392339

23402340
if (timeout != TimeSpan.MaxValue)
23412341
{
2342-
_timer = new Timer(s_timeoutCallback, this, timeout, TimeSpan.FromMilliseconds(-1));
2342+
_timer = new Timer(s_timeoutCallback, this, timeout, Timeout.InfiniteTimeSpan);
23432343
}
23442344
}
23452345

@@ -2350,7 +2350,7 @@ internal static void End(IAsyncResult result)
23502350

23512351
void IWaiter.Signal()
23522352
{
2353-
if ((_timer == null) || _timer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1)))
2353+
if ((_timer == null) || _timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan))
23542354
{
23552355
Complete(false);
23562356
_manager._channel.Closed -= OnClosed;
@@ -2363,7 +2363,7 @@ void IWaiter.Signal()
23632363

23642364
private void OnClosed(object sender, EventArgs e)
23652365
{
2366-
if ((_timer == null) || _timer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1)))
2366+
if ((_timer == null) || _timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan))
23672367
{
23682368
Complete(false, _manager._channel.CreateClosedException());
23692369
}
@@ -2406,7 +2406,7 @@ internal class SessionIdleManager
24062406
private SessionIdleManager(IChannelBinder binder, TimeSpan idle)
24072407
{
24082408
_binder = binder;
2409-
_timer = new Timer(new TimerCallback(GetTimerCallback()), this, idle, TimeSpan.FromMilliseconds(-1));
2409+
_timer = new Timer(new TimerCallback(GetTimerCallback()), this, idle, Timeout.InfiniteTimeSpan);
24102410
_idleTicks = Ticks.FromTimeSpan(idle);
24112411
_thisLock = new Object();
24122412
}
@@ -2439,7 +2439,7 @@ internal void CancelTimer()
24392439
lock (_thisLock)
24402440
{
24412441
_isTimerCancelled = true;
2442-
_timer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
2442+
_timer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
24432443
}
24442444
}
24452445

@@ -2508,7 +2508,7 @@ private void TimerCallback()
25082508
{
25092509
if (!_isTimerCancelled && _binder.Channel.State != CommunicationState.Faulted && _binder.Channel.State != CommunicationState.Closed)
25102510
{
2511-
_timer.Change(Ticks.ToTimeSpan(abortTime - ticksNow), TimeSpan.FromMilliseconds(-1));
2511+
_timer.Change(Ticks.ToTimeSpan(abortTime - ticksNow), Timeout.InfiniteTimeSpan);
25122512
}
25132513
}
25142514
}

src/System.ServiceModel.Primitives/src/System/ServiceModel/Dispatcher/DuplexChannelBinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ internal AsyncDuplexRequest(Message message, DuplexChannelBinder parent, TimeSpa
822822

823823
if (timeout != TimeSpan.MaxValue)
824824
{
825-
_timer = new Timer(new TimerCallback(AsyncDuplexRequest.s_timerCallback), this, timeout, TimeSpan.FromMilliseconds(-1));
825+
_timer = new Timer(new TimerCallback(AsyncDuplexRequest.s_timerCallback), this, timeout, Timeout.InfiniteTimeSpan);
826826
}
827827
if (DiagnosticUtility.ShouldUseActivity)
828828
{

src/System.ServiceModel.Primitives/src/System/ServiceModel/Dispatcher/TerminatingOperationBehavior.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ internal void AfterReply(ref MessageRpc rpc)
4949
{
5050
if (rpc.Operation.IsTerminating && rpc.Channel.HasSession)
5151
{
52-
var timer = new Timer(s_abortChannelTimerCallback, rpc.Channel.Binder.Channel, rpc.Channel.CloseTimeout, TimeSpan.FromMilliseconds(-1));
52+
var timer = new Timer(s_abortChannelTimerCallback, rpc.Channel.Binder.Channel, rpc.Channel.CloseTimeout, Timeout.InfiniteTimeSpan);
5353
}
5454
}
5555

src/System.ServiceModel.Primitives/src/System/ServiceModel/Security/TimeBoundedCache.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private void CancelTimerIfNeeded()
7676
{
7777
if (Count == 0 && _purgingTimer != null)
7878
{
79-
_purgingTimer.Change(TimeSpan.FromMilliseconds(-1), TimeSpan.FromMilliseconds(-1));
79+
_purgingTimer.Change(Timeout.InfiniteTimeSpan, Timeout.InfiniteTimeSpan);
8080
_purgingTimer.Dispose();
8181
_purgingTimer = null;
8282
}
@@ -90,7 +90,7 @@ private void StartTimerIfNeeded()
9090
}
9191
if (_purgingTimer == null)
9292
{
93-
_purgingTimer = new Timer(new TimerCallback(PurgeCallback), this, _purgeInterval, TimeSpan.FromMilliseconds(-1));
93+
_purgingTimer = new Timer(new TimerCallback(PurgeCallback), this, _purgeInterval, Timeout.InfiniteTimeSpan);
9494
}
9595
}
9696

@@ -420,7 +420,7 @@ private static void PurgeCallbackStatic(object state)
420420
self.PurgeStaleItems();
421421
if (self.Count > 0 && self._purgingTimer != null)
422422
{
423-
self._purgingTimer.Change(self._purgeInterval, TimeSpan.FromMilliseconds(-1));
423+
self._purgingTimer.Change(self._purgeInterval, Timeout.InfiniteTimeSpan);
424424
}
425425
}
426426
finally

0 commit comments

Comments
 (0)