我目前正在设计一些内部API,我使用异步CTP和新等待
/ 异步
关键词。
I'm currently designing some internal APIs where I use the Async CTP and its new await
/async
keywords.
有没有关于如何将这些API应该在设计的任何准则或最佳做法?
Are there any guidelines or best practices on how these APIs should be designed?
具体做法是:
我应该同时提供同步和方法的异步版本? (即任务DoStuffAsync()
的和的无效DoStuff()
如果所有的异步方法我可以公开的形式异步任务< T> GetStuffAsync()
(即方法名末尾带异步
)或者是确定有东西名为 GetStuff()
是awaitable?
Should I provide both a synchronous and an asynchronous version of methods? (i.e. Task DoStuffAsync()
and void DoStuff()
Should all async methods I expose be in the form async Task<T> GetStuffAsync()
(i.e. method name end with Async
) or is it ok to to have something named GetStuff()
be awaitable?
我不明白,这还不是全部黑色或白色在这里,它取决于问题的方法,但是我正在寻找的一般准则。
I do understand that it's not all black or white here, and that it depends on the method in question, but I'm looking for general guidelines.
好不容易找到了掘金队,大多数出版物都集中在客户端编程方面。好东西是:
Hard to find the nuggets, most publications are focused on the client programming side. Good stuff is:
系统白皮书基于任务的异步模式。下载是这里(注:慢今早回应)。 斯蒂芬Toub了presentation在的Windows构建谈到优化模式,许多重要的提示。有视频,也可的上一篇:我怎样才能加载.NET程序集的旧版本?加载、旧版本、程序、NET
下一篇:是HashAlgorithm.ComputeHash()状态?状态、HashAlgorithm、ComputeHash