- 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.
- DevOps with Kubernetes
- 數據庫原理及應用(Access版)第3版
- 算法基礎:打開程序設計之門
- Java編程指南:基礎知識、類庫應用及案例設計
- C語言程序設計教程(第2版)
- Hands-On C++ Game Animation Programming
- 云計算通俗講義(第3版)
- 數據結構(C語言)
- 深入淺出Serverless:技術原理與應用實踐
- 微信小程序全棧開發技術與實戰(微課版)
- Building Wireless Sensor Networks Using Arduino
- AutoCAD 2009實訓指導
- Scrapy網絡爬蟲實戰
- Professional JavaScript
- 絕密原型檔案:看看專業產品經理的原型是什么樣