APM uses BeginXXX/EndXX pairs and the Event-based Asynchronous Pattern (EAP) uses XXXAsync and XXXCompleted pairs, but I haven't seen anything standard on how to name methods that return a task.
I have been using XXXTask:
Data GetData()
Task<Data> GetDataTask()
but was wondering if a more standard approach has developed
“Naming convention is a set of rules for choosing the character sequence to be used for identifiers which denote variables, types, functions, and other entities in source code and documentation” — Wikipedia.
Method names should always begin with a lower case character, and should not contain underscores.
If a public method is Task-returning and is asynchronous in nature (as opposed to a method that is known to always execute synchronously to completion but still returns a Task for some reason), it should have an “Async” suffix. That's the guideline.
For C# 5.0 (with .NET 4.5), the naming convention is XXXAsync for task returning methods.
If there already exists a method with this naming (for instance, on the WebClient already has a DownloadDataAsync method that implements the EAP pattern), then the Task returning async method should be named XXXTaskAsync.
I'd recommend using the patterns in the ParallelExtensionsExtras library since that's done by the same team that made the TPL in the first place :)
http://blogs.msdn.com/b/pfxteam/archive/2010/05/04/10007557.aspx
Their pattern seems to be the same as yours: [SyncAction]Task for the method that does SyncAction async via a Task (which is returned) - DownloadDataTask, SendTask, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With