c# - Xamarin Forms change text of button while wait -
i'm using xamarin forms develop cross-platform app.
i want change text of button "do something" "wait", while code processing routine, , "do something" after code finish run.
the problem is: button text change after code completed.
simple exemple:
private void button_clicked(object sender, eventargs e) { var btn = (button)sender; btn.text = "wait"; ...some code.. btn.text = "do something"; }
there's way "force" update of text "wait" before code finish?
private async void btn1_clicked(object sender, eventargs e) { btn1.text = "wait"; await task.run(async () => { (int = 1; <= 5; i++) { //if code requires ui wrap in begininvokeonmainthread //otherwise run code device.begininvokeonmainthread(() => { btn1.text = $"wait {i}"; }); await task.delay(1000); } }); btn1.text = "done"; }
Comments
Post a Comment