Hi,

how to call web service (asmx) periodically in background using android
service?

Easiest way I know of is this. As a global, set a timer with an interval of every couple of mins (or however long you need it to be). When the timer is done, so something like this would do

public void EnableMessageTimer()
{
      timer = new System.Timers.Timer();
      timer.Interval = 15000;
timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
      timer.Start();
}

then in your timer_Elapsed call the webservice. Depending on what the webservice does depends then on how you handle it. For example, if it's an async service, when it returns if there is any UI output, you'll need to use RunOnUiThread to jump onto the UI thread.

If the service isn't Async, you can use something like System.Threading.Tasks or ThreadPool.QueueUserWorkItem and that will do what you need.

Paul

--
"Space," it says, "is big. Really big. You just won't believe how vastly, hugely, mindbogglingly big it is. I mean, you may think it's a long way down the road to the chemist's, but that's just peanuts to space, listen..."
Hitch Hikers Guide to the Galaxy, a truly remarkable book!

_______________________________________________
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid

Reply via email to