How to run lengthy tasks from an ASP.NET page? -
i've got asp.net page simple form. user fills out form details, uploads document, , processing of file needs happens on server side.
my question - what's best approach handling server side processing of files? processing involves calling exe. should use seperate threads this?
ideally want user submit form without web page hanging there while processing takes place.
i've tried code task never runs on server:
action<object> action = (object obj) => { // create .xdu file job string xdufile = launcher.createsinglejobbatchfile(languagepair, sourcefilelocation); // launch job launcher.processjob(xdufile); }; task job = new task(action, "test"); job.start();
any suggestions appreciated.
you invoke processing functionality asynchronously in classic fire , forget fashion:
in .net 4.0 should using new task parallel library:
task.factory.startnew(() => { // work });
if need pass argument action delegate this:
action<object> task = args => { // work args }; task.factory.startnew(task, "someargument");
in .net 3.5 , earlier instead way:
threadpool.queueuserworkitem(args => { // work });
related resources:
Comments
Post a Comment