asp.net - Global.asax Application_Error 是异步的吗?

标签 asp.net

我需要使用复杂的长时间工作逻辑来处理丢失的请求文件。

我可以在 Application_Error 中做到这一点,但不确定它本身是否是异步的?

如果需要 5 分钟或更长时间才能工作,此处理程序是否会一直阻止其他用户?

最佳答案

Application_Error 参与页面处理,从您加载的页面调用,因此问题是页面或处理程序本身是否异步。

是的,如果你不使用session,当然如果你不使用其他同步锁,比如mutex,或者数据库open/read/write

这是为什么呢?因为 session 锁定了完整的处理,请看这个问题/答案: call aspx page to return an image randomly slow
ASP.NET Server does not process pages asynchronously
Trying to make Web Method Asynchronous
Web app blocked while processing another web app on sharing same session
What perfmon counters are useful for identifying ASP.NET bottlenecks?
Replacing ASP.Net's session entirely
File upload and result pooling kills ASP.NET web app

因此,为简单起见,Application_Error 只是一个静态函数调用,但连接到页面或处理程序的处理。确保页面或处理程序没有相互阻塞,一切正常。

另一方面,一个 5 分钟的处理,如果您尝试将其中的 500 个放在一起而不将它们放在查询列表中,您可能会遇到其他问题。

我只是做了一个简单的测试,将System.Threading.Thread.Sleep(20000);放在Application_Error上报错,继续加载其他页面,和工作。

关于asp.net - Global.asax Application_Error 是异步的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13968147/

相关文章:

asp.net - 阻止 EF Core 构建具有前缀名称 IdentityDbContext 的表

c# - asp.net 中的转发器项目命令

php - 使用 setTimeOut 进行 ajax 调用

asp.net - 使用 VB.NET 从纯字符串解析 URL ?a=b 参数

c# - MiniProfiler 结果 UI 显示空名称,因为使用了 SqlServerStorage

c# - string.format 序列能否以任意顺序出现

c# - 为什么要使用全局资源?

c# - 将选项模式与 Azure Key Vault 结合使用?

asp.net - RaisePostBackEvent 未触发

javascript - 如何从 updatepanel 中的另一个按钮单击事件触发 onclientclick 按钮