---
description: async and await
---

# Asynchronous Programming

{% embed url="https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/" %}

*   `async void` **should only be used for event handlers otherwise you should always avoid it.** Instead [`async Task` can be used which also does not require any return type.](https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/async-scenarios)\


    `async void` is the only way to allow asynchronous event handlers to work because events do not have return types (thus cannot make use of `Task` and `Task<T>`). Any other use of `async void` does not follow the TAP model and can be challenging to use, such as:

    * Exceptions thrown in an `async void` method can't be caught outside of that method.
    * `async void` methods are difficult to test.
    * `async void` methods can cause bad side effects if the caller isn't expecting them to be async.
