Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
How to work withLong Running Processes using ASP.NET with C#
Posted

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!
 
Share this answer
 
v2
Comments
Nelek 13-Aug-14 9:42am    
Nice explanation
Kim Togo 13-Aug-14 9:46am    
Good explanation
Member 10619915 14-Aug-14 3:16am    
Hi Manfred
Please provide any url/link reference [using C# Code...(I want any practical example link refernce.)]
 
Share this answer
 
Comments
Kim Togo 13-Aug-14 9:48am    
Question, what does this have to do with ASP.NET and long running process? - See solution 2.
Member 10619915 14-Aug-14 3:02am    
I want add item in a list or datatable object and save it in database but due to some check condition with useing for loop/ foreach it's take long process for complete it so many time it's failed so how to manage it.


Ex: You want doctor appointment schedule using with asp:calender controls...
Thanks7872 14-Aug-14 3:04am    
You have already been advised how to manage it. Now its your turn to understand and implement it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900