0
votes

We are building Xamarin forms app to run on iOS, Android and Windows 10. We are data binding view model to UI which has List View control. We want the data to be refreshed from rest service, every 3-5 seconds when user is viewing the app. We don't want the data to refresh when app is in background, but refresh the data as soon as app is foreground. I tried using Xamarin.Forms.Device.StartTimer and await Task.Delay, but this does not seem to be working very well, sometimes the data does not refresh when not in interactive debug mode especially with Xamarin.Forms.Device.StartTimer , I am not sure what is going wrong as I am not able to do logging on device. On using await Task.Delay, sometimes the Task gets cancelled. In app onresume event, code makes rest service call which fails with connection refused error.

So I wanted to know which is the best way to handle data refresh, any ideas?

Thanks in advance

1
have you tried using platform specific services? arteksoftware.com/backgrounding-with-xamarin-forms - nicks

1 Answers

0
votes

At last to do periodic refresh, i used Task.Delay and a boolean variable to known whether refresh needs to be performed or not. If user navigates away from the page, i set the boolean variable to false to stop the refresh.