Does Xamarin.Forms support periodic background tasks?

It's hard for me to find documentation on supporting background tasks for Xamarin.Forms. Does Xamarin.Forms support periodic background jobs?

I need to implement this for both Windows Phone 10 and Android.

+4
source share
3 answers

, , .

, , System.Threading.Timer(.net class) - Activity/Service

private System.Threading.Timer timer;

OnCreate

TimeSpan timerTime = new TimeSpan(0, 0, 0, 0, 1000);
            timer = new System.Threading.Timer(new System.Threading.TimerCallback(OnTimerFired), null, timerTime, timerTime);

OnDestroy

if (timer != null)
            {
                timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite);
                timer.Dispose();
                timer = null;
            }


private void OnTimerFired(object state)
{
    Do some periodic job
}
-1
-1
source

Source: https://habr.com/ru/post/1625315/


All Articles