1

Scenario I have an web application which needs some calculations and processing on data. This job is a long running job(few hours). Job is initiated by user.

Requirement.

  1. User Clicks on Process Data.

  2. Some functions are called to start data processing.

  3. Data Processing runs for hours.

  4. User is given feedback of percentage completed etc.

  5. Even if user logs off and then again log on he should get this feedback.

The requirement is somewhat similar to Spiceworks. Where it runs in background to detect the devices/computers in network and the user is notified in his page about the progress. But spicework uses windows service. We don't want to us windows service.

Now the question is.

  1. What if user closes the page, will the task still run in background.

  2. This task has to be completed fully.If terminated in between output will not have any meaning.

  3. How to actually to design this long running process. In ASP.Net environment.

  4. Also is there a way to show all/same user who logs in the status of processing.

Sachin Chavan
  • 5,578
  • 5
  • 49
  • 75
  • Why don't you want to use a service? This is exactly the sort of problem that services are intended to solve. – 3Dave Mar 11 '11 at 05:29
  • @David Lively. Yes. This is very much right candidate for service. But my reservations are due to: 1. Its an existing code(Too big and not so good). 2.This is installed at various clients places. 3. Support of managing the permissions etc will be huge. – Sachin Chavan Mar 11 '11 at 05:45

1 Answers1

1

There are multiple ways to schedule a job in the background. You can use SQL Job, Windows Service or Scheduled Tasks.

I would design it like this:

From my ASP.NET page - I will store an indication in the database for the job to start which will then be picked by the scheduled task. This task is nothing but a console application which pulls data from the database to see which tasks user initiated and then take the next action in there.. For the percetage complete you can store those values from your job into DB and your page will access the dB to show it to user anytime they come to the page.

Here is another thread where long running tasks in IIS are discussed: Can I use threads to carry out long-running jobs on IIS?

Community
  • 1
  • 1
sajoshi
  • 2,733
  • 1
  • 18
  • 22
  • +1. Yes. I am doing the same. Except the scheduled task part. The jobstatus is stored in table and from there it is displayed to user. But i dont what a scheduler or external utility to run. I want it it in the IIS context. – Sachin Chavan Mar 11 '11 at 05:40
  • IIS is designed to process HTTP requests which is usually short lived. I have edited my answer to include another thread. Please check if it gives you some insight. – sajoshi Mar 11 '11 at 05:49
  • again a +1 (if i was able to) :) for right pointer. I have already gone through same and also checked the blogpost of jeff where he mentions how they handle this on Stackoverflow.com. But still I am not convinced. The question I put forward is for the reason of catching as many options available and getting a better solution. – Sachin Chavan Mar 11 '11 at 05:53