首页 新闻 会员 周边 捐助

在同步方法中调用HostingEnvironment.QueueBackgroundWorkItem()的问题

0
悬赏园豆:30 [待解决问题]

在同步方法中调用HostingEnvironment.QueueBackgroundWorkItem()方法,总是不执行,在异步方法中调用没这个问题。

C#
dudu的主页 dudu | 高人七级 | 园豆:30939
提问于:2016-08-28 16:50
< >
分享
所有回答(1)
0

https://msdn.microsoft.com/en-us/library/dn636893(v=vs.110).aspx

文档中这样描述:

Differs from a normal ThreadPool work item in that ASP.NET can keep track of how many work items registered through this API are currently running, and the ASP.NET runtime will try to delay AppDomain shutdown until these work items have finished executing. This API cannot be called outside of an ASP.NET-managed AppDomain. The provided CancellationToken will be signaled when the application is shutting down.

QueueBackgroundWorkItem takes a Task-returning callback; the work item will be considered finished when the callback returns.

其中 and the ASP.NET runtime will try to delay AppDomain shutdown until these work items have finished executing。

try to delay 。是不是 ‘不保证在 AppDomain 关闭之前, 等待 WorkItem 完成执行’ 的意思。

 

 

长蘑菇星人 | 园豆:1832 (小虾三级) | 2016-08-29 11:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册