How to correctly implement a TAP method?

Viewed 11327

I want to provide a task-based asynchronous pattern-style method. When awaiting the method, I could not find any difference between these two ways of providing the method:

// GetStats is a delegate for a void method in this example
public Task GetStatsAsync()
{
    return Task.Run(GetStats);
}

public async Task GetStatsAsync()
{
    return await Task.Run(GetStats);
}

// Usage:
await GetStatsAsync();
// Difference?

The upper method seems to have less overhead than the lower one. When looking at the MSDN blogs, I noticed that they seem to use the lower method. (For example in this article)

Why? What exactly is the difference? They both seem to work.

2 Answers
Related