Hi, My code looks like this:
class MyScreen { ... Task VeryLongTask; public override void ViewDidLoad { VeryLongTask=new Task(LongTask); VeryLongTask.Start(); ... } private void MyButton_TouchUpInside(...) { if(VeryLongTask.Status==TaskStatus.Running) {// set the button's text to tell user task is still running this.MyButton.SetTitle("Still running"); } // block here and wait for the task to finish VeryLongTask.Wait(); // task finished, now change button's text, though it will not be seen by the user this.MyButton.SetTitle("Ready"); // Show another screen } public void LongTask(){...} }
Basically, I first run a long task and then wait on it in the button's event handler. The problem is that when I click the button, according to the code the button's text should change, but it does not. I would have thought it should change since the task runs in the background and the UI should be responsive. I am running this on the iOS simulator. Have not tested yet with a real iPhone
What am I doing wrong?
Thank you, donescamillo@gmail.com