I know I am asking an exist question. I read many articles about this but I still confused. Maybe my English skill is not good enough.
Here is my code at first:
void dovoid1(){
//dosomething
}
void dovoid2(){
//dosomething
}
void dovoid3(){
//dosomething
}
and
void action()
{
dovoid1();
Thread.Sleep(1000);
dovoid2();
Thread.Sleep(1000);
dovoid3();
Thread.Sleep(1000);
action();
}
As you see, the void action() will do some task, and have a sleep between them. Afer that, it repeat itself. Now I want to avoid Thread.Sleep() because it blocks the UI. So I try to use async/await.
private async void action()
{
dovoid1();
Task.Delay(1000);
dovoid2();
Task.Delay(1000);
dovoid3();
Task.Delay(1000);
action();
}
But it give me errors. I don't know where and When I should use async or await. Thank you!