Forum Cross Platform with Xamarin

Run task in EventHandler asynchronously

I have some method that takes some time to run because it must get answer from web service.
Problem is that I must put that answer on Label on my form, but I can't, since code, in event handler Button.Clicked, runs synchronously and Label.Text property updates faster, then Task returns answer.
Also if set method's type from void to Task app crashes when event handler trying run next row after that Task's call.

request.Clicked += (e, sender) => { result.Text = "in progress..."; var task = LayeredArchitecture.ServiceLayerFolder.CustomServiceClass.MakeRequest(id.Text);\\\\\ }

Best Answer


Sign In or Register to comment.