“Thread was being aborted” exception raised in excuting Hangfire job

有些话、适合烂在心里 提交于 2019-12-25 00:17:22

问题


I have a Hangfire (with SqlServer for persistence) job which query some data from database. Then generate an Excel with NPOI with these data, and sent it via Email to users.

The data is not so large, only like 1,000 rows. So the job executes in seconds. However, I get "Thread was being aborted" exception when generating Excel or sending mail.

I guess there is something like Timeout, which kills the thread. Does anyone have the same issue? Any solutions?


回答1:


Alright. Actually I made a stupid mistake in here. Before I generate an Excel, I have a template. The template will be copied to HttpRuntime.BinDirectory first (I am trying to avoid the resource conflict). This HttpRuntime.BinDirectory is the root cause which makes the thread aborted.

When there are any changes in websites bin folder, IIS will renew the AppDomain (or ApplicationPool?). That will abort current running threads.



来源:https://stackoverflow.com/questions/51940607/thread-was-being-aborted-exception-raised-in-excuting-hangfire-job

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!