简体   繁体   English

单独的服务,用于处理ASP.NET中长期运行的任务

[英]Separate service for processing long running tasks in ASP.NET

I would like to makea windows service. 我想做一个Windows服务。 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. 每当我的ASP.NET应用程序的用户必须执行耗时的任务时,IIS就会将该任务交给服务,该服务将返回一个令牌(该任务的临时名称),而在后台该服务将执行该任务。 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". 此外,还有一个适用于系统管理员的WinForms应用程序,该应用程序允许添加特殊的ADMIn任务,例如“清除孤立的文件”或“非活动用户的存档数据”。

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. 您能否指出我可以从一个整体概念入手的东西-我知道我可以在Windows服务上用google搜索,而且我自己可以从头开始做,但是时间很重要,所以也许您知道已经在那里,我可以使用块来构建。

I'd love some feedback on a service I've been working on to run/queue background tasks. 我希望对我一直在运行的一项服务进行反馈/排队/执行后台任务。 http://sharphooks.net 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. 它涉及实现一种界面方法,通过Web UI上传文件,然后通过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 例如ID_Task / Name / XML_Object(序列化,包含信息)/状态
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. XML_Object将包含,例如,下一步。

Then, you make a windows service wihch tick every...5 or 10 minutes and check your table. 然后,使Windows服务每隔... 5或10分钟打一次勾并检查表。
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. 您可以检查状态是否不是您期望的每一步状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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