简体   繁体   中英

Separate service for processing long running tasks in ASP.NET

I would like to makea windows service. whenever the user of my ASP.NET application has to do a time-consuming task, the IIS would give the task to the service which will return a token(a temporary name for the task) and in the background the service would do the task. At anytime, the user would see the status of his/her task which would be either pending in queue, processing, or completed. The service would do a fixed number of jobs in parallel, and would keep a queue for the next-incoming tasks. In addition there would be a WinForms application for system administrator that would allow adding special ADMIn tasks such as "Clean orphaned files" or "archive data of inactive users".

Can you point me to something that can jump start me on this as a whole concept - I know I can google for windows services and I am able to do it myself from scratch but time is of the Essence so maybe you know of something that is already there and i can use block to build out of.

I'd love some feedback on a service I've been working on to run/queue background tasks. http://sharphooks.net

It involves implementing a single method of an interface, uploading your files via a web UI, then posting new jobs via an HTTP POST.

The simple way I think :

You can use a database table to make your pending tasks.
A simple table (or several...) with all the informations you need.
For example ID_Task/Name/XML_Object(serialized, contains informations)/Status
When the user want to add a task, you had a row in your table.

The XML_Object will contains, for example, the next step to do.

Then, you make a windows service wihch tick every...5 or 10 minutes and check your table.
If it see a task with the status "Pending", it launch the task in a backgroundworker and continue watching.
And it update the status' task on some steps.
You can check if the status is not the one you expect for each step.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM