How to implement a very long background task in an ASPP WebAPI application

I am writing a WebAPI application to perform a number of lengthy background processing tasks.

I notice that my task of loading test data is being killed by System.Threading.ThreadAbortException, even after I turned off pool reloading in IIS. I know that there is a way to run very long (several hours) background tasks in a web application, but I just don’t know how exactly this is done - either specific configuration settings, encoding technique, Wen.config parameter, etc ... Can anyone share some practical way to do this, please?

+2
source share
2 answers

You do NOT want to use IIS / ASP.Net to start a long process, it is not intended for this.

Use it only for the initial call to Web.API, to start the service using MSMQ or to insert a row into a table that tells your individual process what to do.

Create a separate application - or a console application, where you will use the Windows scheduler to periodically launch the application and check for new work items; or a Windows service that periodically checks your work item store for work items. Then you can use ThreadPool, etc. To start your process asynchronously.

+2
source

, WebAPI Windows TopShelf. , WebAPI , IIS.

!

-Eugene

0

All Articles