How to run lengthy tasks from an ASP.NET page?

Posted by Jimmy C on Stack Overflow See other posts from Stack Overflow or by Jimmy C
Published on 2011-02-18T14:17:50Z Indexed on 2011/02/18 15:25 UTC
Read the original article Hit count: 209

Filed under:

I've got an ASP.NET page with a simple form. The user fills out the form with some details, uploads a document, and some processing of the file then needs to happens on the server side.

My question is - what's the best approach to handling the server side processing of the files? The processing involves calling an exe. Should I use seperate threads for this?

Ideally I want the user to submit the form without the web page just hanging there while the processing takes place.

I've tried this code but my task never runs on the server:

Action<object> action = (object obj) =>
{
      // Create a .xdu file for this job
       string xduFile = launcher.CreateSingleJobBatchFile(LanguagePair, SourceFileLocation);

      // Launch the job                 
      launcher.ProcessJob(xduFile);
};

Task job = new Task(action, "test");
job.Start();

Any suggestions are appreciated.

© Stack Overflow or respective owner

Related posts about asp.net-mvc-2