- C# 7 and .NET Core Cookbook
- Dirk Strauss
- 169字
- 2021-07-03 00:11:55
Generalized async return types
If you use async/await (if not, check it out) the following feature of C# 7.0 will come in really handy. The only supported return types used to be Task<T>, Task, and void. Even then, void was also only used with event handlers such as a button click. The challenge, however, was that a Task<T> was allocated in situations where the result of the async operation was available at the time of awaiting. But, what does this even mean? Well consider an async method that returns a Task<T> : and that value has a time to live of n amount of seconds. If the async method is called within the time to live period, why go to the trouble of allocating another Task<T> object? This is where the ValueTask<T> comes into play; it will allow other types to be defined so that you can return them from an async method. This, therefore, reduces the Task<T> allocations, which in turn will lead to performance gains.
- arc42 by Example
- AWS Serverless架構:使用AWS從傳統部署方式向Serverless架構遷移
- Machine Learning with R Cookbook(Second Edition)
- PHP+MySQL網站開發項目式教程
- Learning OpenStack Networking(Neutron)
- Visual Foxpro 9.0數據庫程序設計教程
- D3.js By Example
- Citrix XenServer企業運維實戰
- 你真的會寫代碼嗎
- 打造流暢的Android App
- Implementing DevOps with Ansible 2
- Implementing NetScaler VPX?(Second Edition)
- Selenium自動化測試實戰:基于Python
- Learning Adobe Muse
- 前端程序員面試筆試通關寶典