tabs ↹ over ␣ ␣ ␣ spaces

by Jiří {x2} Činčura

Task.CompletedTask in .NET 4.6

12 Feb 2015 1 mins .NET, C#, Multithreading/Parallelism/Asynchronous/Concurrency

I wrote about fast path optimizations with having already completed task prepared before in my “Better “cached completed Task””. At that time the was no way to directly access already completed Task the TPL has.

Although you could do it using the trick described there, it was really looking cryptic for somebody reading the code. You could wrap it into your own well-named property, but you know…

Luckily in .NET 4.6 the before internal Task.CompletedTask property is now public. It’s not that it will make your code faster than before. Really not. It’s just ready there for you to use. And because of the name the code will also look more self-descriptive.

Now to just wait for .NET 4.6 to RTM.

Profile Picture Jiří Činčura is .NET, C# and Firebird expert. He focuses on data and business layers, language constructs, parallelism, databases and performance. For almost two decades he contributes to open-source, i.e. FirebirdClient. He works as a senior software engineer for Microsoft. Frequent speaker and blogger at www.tabsoverspaces.com.