如何使用ASP.NET与C#一起使用Long运行进程 [英] How to work withLong Running Processes using ASP.NET with C#

查看:63
本文介绍了如何使用ASP.NET与C#一起使用Long运行进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用ASP.NET与C#

How to work withLong Running Processes using ASP.NET with C#

推荐答案

使用长运行进程不要直接从网页上执行此操作是我的建议。为什么会这样,你可能会问。简单:

工作流程会定期回收,因此您的线程也会停止运行,您甚至不知道已经完成了多少工作以及在哪里恢复(如果已将其编码到解决方案)。有人可能会反驳说,可以从网页开始一个单独的流程,这个流程要好一点,但仍然缺乏。

启动一个单独的流程将使它即使在工作流程中也能保持活跃状态(重新启动)重新开始,但是一旦工作人员重新启动,就会以某种方式恢复正在进行的操作的知识。所以你真正需要的是一个中间进程,它允许你启动进程/线程,传递参数给它们并接收返回值。

中间进程将执行内务处理,启动进程/线程,跟踪进程'/线程的进度并保持结果,直到它们可以被传递/返回到工作进程(如果您不知道:工作进程是在ASP.net中运行网页的位置) )。



如果没有中间过程,那么当高负荷投入系统时会发生这样的问题。如果启动了许多额外的进程,您可能会削弱您的Web服务器。中间过程可以被编程为仅启动多个进程/线程,然后等待直到一个终止,然后才开始从队列发出下一个请求。它还可以用于将此处理卸载到其他服务器,因此具有IIS及其应用程序的系统保持响应。



干杯!
Don't do it directly from the webpage is my advice. Why is that so, you might ask. Simples:
Worker processes are recycled regularily and thus your threads will also stop running and you won't even know how much of the work has been done and where to resume (if this has been coded into the solution at all). One might counter that it is possible to start a separate process from the webpage, which is a bit better, but is still lacking.
Starting a separate process will allow it to stay alive even when the worker process(es) get restarted, but the knowledge about an ongoing operation will somehow have to be restored once the workers have been restarted. So what you really need is an intermediary process that allows you to start processes/threads, pass parameters to them and receive return values.
The intermediary process will do the house keeping, starting the processes/threads, keeping track of a process' / thread's progress and keep the results around until they can be delivered/returned to the worker process (in case you don't know: The worker process(es) are where the webpages are run in ASP.net).

A whole other issue when going without an intermediary process is what happens when high load is put onto the system. If a lot of extra processes are started you might cripple your webserver. The intermediary process can be programmed to only start a number of processes/threads and then wait until one terminates before starting the next request from the queue. It can also be used to offload this processing to other servers so the systems with the IIS and the application on them stay responsive.

Cheers!


请参阅:



http://msdn.microsoft.com/en-us/library/ms173178.aspx [ ^ ]



http://msdn.microsoft.com/en-in/library/aa645740(v = vs.71).aspx [ ^ ]



问候......
See these :

http://msdn.microsoft.com/en-us/library/ms173178.aspx[^]

http://msdn.microsoft.com/en-in/library/aa645740(v=vs.71).aspx[^]

Regards...


这篇关于如何使用ASP.NET与C#一起使用Long运行进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆