System.Timers.Timer vs System.Threading.Timer

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

System.Timers.Timer vs System.Threading.Timer

Message par ForumBot »

System.Timers.Timer vs System.Threading.Timer
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: System.Timers.Timer vs System.Threading.Timer

Message par ForumBot »

This article offers a fairly comprehensive explanation:

"[Comparing the Timer Classes in the .NET Framework Class Library](https://web.archive.org/web/20150329101415/https://msdn.microsoft.com/en-us/magazine/cc164015.aspx)" - also available [as a .chm file](http://download.microsoft.com/download/3/a/7/3a7fa450-1f33-41f7-9e6d-3aa95b5a6aea/MSDNMagazineFebruary2004en-us.chm)

The specific difference appears to be that `System.Timers.Timer` is geared towards multithreaded applications and is therefore thread-safe via its `SynchronizationObject` property, whereas `System.Threading.Timer` is ironically not thread-safe out-of-the-box.

I don't believe that there is a difference between the two as it pertains to how small your intervals can be.
Répondre

Revenir à « .NET & C# »