Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Task.Delay for long times doesn't work

$
0
0

I have a Task.Delay() function.

The code activates it, and waits for 10 minutes. Works fine.
The code activates it, suppose to wait 1 hour, but it always waits more ! (more = few minutes more).

I thought it because the app enters a sleep mode, but when I lock the phone,
the app enters to a sleep mode and it works fine.

Does someone have an idea?
The device is an Android device, and I develop the app using Xamarin.Forms.

This is the code:
try{
_myTask= Task.Delay(TimeSpan.FromSeconds(secondsToWait), someTokenForCancel);

     //some code..

     await _myTask;
}catch(TaskCanceledException e)
{
    //some code.. 
}

Viewing all articles
Browse latest Browse all 204402

Trending Articles