Most tutorials (mine included) use Thread.Sleep() as an easy way to simulate a method call that takes awhile to return, but you shouldn't be calling that in your situation. In the code you posted, it will always sleep 10 seconds before even trying to call the service. Simply removing the call to Thread.Sleep() will get you what you want, since service.getUsers() will return (I assume) whenever it's done getting its data.
On Mon, Sep 19, 2011 at 5:12 AM, Mittchel Van Vliet <mittc...@gmail.com>wrote: > Hello everyone, > > Currently I am working with webservices in Monodroid and MonoTouch.. but > I've got one problem: > With webservices sometimes you've the problem that a webservice needs time > to load, so the solution is to put in a thread right? > > But I've only seen tutorials where you put a solid amount of seconds the > thread sleeps.. but how can you let him sleep until it recieves data? > Because if I do the following: > > thread.Sleep(10000); > service.getUsers(); > > And the service is done in 5 seconds, then the thread sleeps for another 5 > extra seconds.. > Another danger is that if the thread sleeps for 10 seconds, and the method > takes 5 seconds.. then the app will crash.. > > So how am I able to let the thread sleep until the method recieves data, > like Facebook apps does? > > Greetings! > > _______________________________________________ > Monodroid mailing list > Monodroid@lists.ximian.com > > UNSUBSCRIBE INFORMATION: > http://lists.ximian.com/mailman/listinfo/monodroid > >
_______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid