How can i solve 'cannot await 'void'' error in c#?

This error indicates you're trying to use the `await` keyword with a method that returns void.

Example:


public async void MyVoidMethod() { ... }
...
await MyVoidMethod();

Solution:


public async Task MyTaskMethod() { ... }
...
await MyTaskMethod();
For methods you wish to `await`, return a `Task` instead of `void`.

Beginner's Guide to C#