I have a method like this:
public void ButtonClicked()
{
var MyResult=MyTimeConsumingTask(MyClassProperty);
}
As you can see, it blocks UI thread.
I can create a backgroundWorker and run this method on that background thread, but I am looking to see if using Async and Await would help me to simplify this.
This is not working:
public async void ButtonClicked()
{
await var MyResult=MyTimeConsumingTask(MyClassProperty);
}
How can I do this?
I like to know the general solution, but also noting that MyimeConsumingTask is waiting for some data on network, how can I solve the problem?