What's a benefits or drawbacks of using Device.StartTimer
vs System.Threading.Timer
?
Both are firing on background threads, both are cross-platform and netstandard2 compatible. System.Threading.Timer
has a bonus points of being non-Xamarin specific.
What should I use and when?
System.Threading.Timer
seems to use dedicated thread for all timers. Am I right, or do Xamarin use another implementation?Official answer from Xamarin documentation team: https://github.com/MicrosoftDocs/xamarin-docs/issues/2243#issuecomment-543608668
Use either.
Device.StartTimer was implemented long before .NET Standard came along, and in those days the Timer class was unavailable to PCL projects. Now that the Timer class is available, there's no advantage/need to use Device.StartTimer. But that API won't vanish, because there will be older projects that still rely on it.
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