Should I reuse timers or allocating new one on demand? Do many sleeping timers timer.Change(Timeout.Infinite, Timeout.Infinite)
consumes resources?
P.S: I'm talking about System.Threading.Timer
class
No, in the current implementation of the .NET framework, timers that are changed to infinite timeout do not consume system ressources (except the memory used to store the instance itself), because they are actually deleted from the internal timer queue:
if (dueTime == Timeout.UnsignedInfinite)
{
TimerQueue.Instance.DeleteTimer(this);
success = true;
}
quoted from reference source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With