If an API has a synchronous method T DoSomething<T>();
, what is the naming convention for the corresponding asynchronous method if it returns Task<T>
?
Task<T> DoSomethingTask<T>();
or
Task<T> DoSomethingAsync<T>();
or something else?
From what I've seen in C# 5 / .NET 4.5, the preferred name is
DoSomethingTaskAsync
orDoSomethingAsync
For example, the WebClient class in .NET 4.5 has methods like
DownloadFileTaskAsync
, because it already had a method namedDownloadFileAsync
, so I assume the use ofTaskAsync
overAsync
is to maintain backwards compatibility.If you are talking about an
async
orawait
method, then from MSDN: