Reputation: 109
A method defined as below cannot return anything. So how does it fit into the normal syntax that such a method has to return "Task". For this reason, the method below will not compile when "async" is removed.
static async Task MyAsyncMethod() { }
Also when you call the method with:
await MyAsyncMethod();
"await" is supposed to be called on awaitable object, but here the return type is "struct Void" which is not awaitable
Upvotes: 0
Views: 96
Reputation: 19106
You can
public async Task DoAsync()
{
// do anything synchron here
// await other Task
}
or
public Task DoAsync()
{
// do anything synchron here
return Task.CompletedTask;
}
or
public Task DoAsync()
{
// do anything synchron here
return Task.FromResult( false );
}
Upvotes: 2