ASP.Net生命线程和衍生任务

时间:2021-02-11 20:58:55

I'm new to ASP.net,

我是ASP.net的新手,

I am writing a webapi to kick off some heavy server side processing which I need assurance will complete.

我正在编写一个webapi来启动一些重要的服务器端处理,我需要保证完成。

At present the ASP.net request kicks off a new Task (Task.Factory.StartNew(...)) then returns a URL the user can poll to find status.

目前,ASP.net请求启动一个新任务(Task.Factory.StartNew(...)),然后返回用户可以轮询以查找状态的URL。

However I am getting the odd ThreadAborted exceptions in the serverside processing tasks and reading this question I am thinking that using Task is not the best option.

但是我在服务器端处理任务中得到奇怪的ThreadAborted异常,并且在阅读这个问题时我认为使用Task不是最好的选择。

Is there a better parallelism/async paradigm for spawning long running server side processes which need assurance of completion ?

有没有更好的并行/异步范例来产生需要保证完成的长时间运行的服务器端进程?

1 个解决方案

#1


1  

IIS can recycle your application at any time so the web server is not the best thing to use for this. Your best bet would be to run a windows service on a separate server and either self host the WebApi in that or use MSMQ to send a message from the web server to the "app" server to initiate the processing.

IIS可以随时回收您的应用程序,因此Web服务器不是最好的用途。您最好的选择是在单独的服务器上运行Windows服务,并自行托管WebApi或使用MSMQ从Web服务器向“app”服务器发送消息以启动处理。

#1


1  

IIS can recycle your application at any time so the web server is not the best thing to use for this. Your best bet would be to run a windows service on a separate server and either self host the WebApi in that or use MSMQ to send a message from the web server to the "app" server to initiate the processing.

IIS可以随时回收您的应用程序,因此Web服务器不是最好的用途。您最好的选择是在单独的服务器上运行Windows服务,并自行托管WebApi或使用MSMQ从Web服务器向“app”服务器发送消息以启动处理。