Ped*_*ntz 70 .net async-await asp.net-core
我在GitHub上偶然发现了一个问题(https://github.com/HTBox/allReady/issues/1313),在那里他们讨论了如何ConfigureAwait(false)在ASP.NET核心中删除代码
呼叫
ConfigureAwait(false)是多余的,什么都不做
我能找到的最好的答案是一个"旁注"(来自Stephen Cleary,https: //stackoverflow.com/a/40220190/2805831 )
ASP.NET Core不再具有"上下文"
那么,ASP.NET Core中ConfigureAwait(false)真的没必要(即使使用完整的.Net Framework)?在某些情况下,它在性能方面是否有任何实际的好处,或者在结果/语义上有所不同?
编辑:如果我将其作为控制台应用程序托管或在IIS中,它在这方面有所不同吗?
Pau*_*ado 73
ConfigureAwait只对在SynchronizationContextASP.NET Core没有的上下文中运行的代码有影响(ASP.NET"Legacy"会这样做).
通用代码仍然应该使用它,因为它可能正在运行SynchronizationContext.
ASP.NET Core SynchronizationContext
Alf*_*ero 22
那这个呢?
At this moment (Feb-2020) Developers on MS Blog recommends use ConfigureAwait(false) in order to Improving performance, Avoiding deadlocks. https://devblogs.microsoft.com/dotnet/configureawait-faq/
I’ve heard ConfigureAwait(false) is no longer necessary in .NET Core. True? False. It’s needed when running on .NET Core for exactly the same reasons it’s needed when running on .NET Framework. Nothing’s changed in that regard.
| 归档时间: |
|
| 查看次数: |
17530 次 |
| 最近记录: |