Asynchronous method that does nothing

Just use Task.CompletedTask to return a completed task:

public Task BeginAsync()
{
     return Task.CompletedTask;
}

If you have a Task<TResult> use Task.FromResult<TResult> to return a completed task with a result:

public Task<bool> BeginAsync()
{
     return Task.FromResult(true);
}

Your current implementation is very inefficient, as it builds the state machine, and also uses a ThreadPool thread to run the empty task.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)