I have a method like this:
private async Task DoSomething()
{
// long running work here.
}
When I call the method like this it blocks t
How are you using await
? This doesn't block the UI:
private async Task DoSomething()
{
await Task.Delay(5000);
}
private async void button1_Click(object sender, EventArgs e)
{
await DoSomething();
MessageBox.Show("Finished");
}
Note that I didn't have to write any verbose callback stuff. That's the point of async
/await
.