Hola!
If you also like to live on the edge, you probably also like a lot to deal with performance issues in your applications. One of the best ways to accomplish this is to add a bad management of concurrent tasks or deal with threads in the wrong way. If you don’t know much about these issues, it is very likely that you think small memory leaks that will give you long nights of joy.
Important: Tasks are not Threads… that’s it.
Another interesting way to achieve performance issues, is to use of Timers in the bad way. When the logic of an application, is guided by Timers, that code smells everywhere.
That’s probably why, our cool Xamarin friends have not implemented a Timer for Xamarin Forms. This saves us a lot of headaches and also prevents evil programmers can generate malicious code.
2 important: So far I have not found a native Xamarin Timer.
Anyways, if you need is a “small Timer hack” then you can use the StartTimer() function. This operation allows you to have a Callback after a certain period of time, so you be able to work on it.
The following code is more than simple to understand how it works.
In Xamarin forums, there are a couple of developers, who using this operation, have created an almost complete implementation of a Timer.
Finally if you really need an Timer, Advanced Timer, is a great option. It is a package NuGet Xamarin Forms that implements a Timer of the classics, Start(), Stop(), and IsEnabled operations.
Saludos @ Madrid
/El Bruno
References
– Xamarin StartTimer() http://developer.xamarin.com/api/member/Xamarin.Forms.Device.StartTimer/
– Xamarin Forums, Timer in PCL https://forums.xamarin.com/discussion/17227/timer-in-portable-class-library
– NuGet Advanced Timer https://www.nuget.org/packages/Mobilist.AdvancedTimer.Forms.Plugin/
This gave me the answer for my issue. Thanks !
LikeLike
Happy to help !
LikeLiked by 1 person