Android : System thread inside a Timer in Android

on Saturday, December 13, 2014


So I have a Timer in my Activity and I want to run that every 10 seconds.


I created a System.Threading.Timer:



timer = new Timer ((o) => {
Action syncAct = new Action (async delegate() {
await FetchData();
});

RunOnUiThread (syncAct);
}, null, 0, 10000);


The problem here is that await FetchData() takes longer than 10 seconds and that causes the timer to go on forever. I need the timer to start every time AFTER the sync completes. How can I do that?


Thank you for your time.


0 comments:

Post a Comment