async Task vs async void

When you call an async void method, or call an async Task method without awaiting it (if the called method contains an await, so it doesn’t block), your code will continue right away, without waiting for the method to actually complete. This means that several invocations of the method can be executing in parallel, but you won’t know when they actually complete, which you usually need to know.

You can take advantage of executing in parallel like this, while also being able to wait for all the invocations to complete by storing the Tasks in a collection and then using await Task.WhenAll(tasks);.

Also keep in mind that if you want to execute code in parallel, you have to make sure it’s safe to do it. This is commonly called “thread-safety”.

Leave a Comment