What's the meaning of “UseTaskFriendlySynchronizationContext”?

后端 未结 2 1781
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 07:47

There is a new app setting in asp.net 4.5


code like this

2条回答
  •  Happy的楠姐
    2020-11-28 08:13

    More details, quoted from ASP.NET 4.5.1 documentation for appSettings on MSDN:

    aspnet:UseTaskFriendlySynchronizationContext

    Specifies how asynchronous code paths in ASP.NET 4.5 behave.

    ...

    If this key value is set to false [default], asynchronous code paths in ASP.NET 4.5 behave as they did in ASP.NET 4.0. If this key value is set to true, ASP.NET 4.5 uses code paths that are optimized for Task-returning APIs. Setting this compatibility switch is mandatory for WebSockets-enabled applications, for using Task-based asynchrony in Web Forms pages, and for certain other asynchronous behaviors.

提交回复
热议问题