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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From what I’ve seen in C# 5 / .NET 4.5, the preferred name is
DoSomethingTaskAsyncorDoSomethingAsyncFor example, the WebClient class in .NET 4.5 has methods like
DownloadFileTaskAsync, because it already had a method namedDownloadFileAsync, so I assume the use ofTaskAsyncoverAsyncis to maintain backwards compatibility.