0

In ASPNET Page I need to spawn a Process to do some CPU heavy work (ffmpeg) . I wish:
a) send response to client without wait for process exit
b) to do something when Process is done
If I do:

Process pc = new Process();
pc.EnableRaisingEvents = true;
pc.StartInfo.UseShellExecute = false;
pc.StartInfo.WorkingDirectory = AppDir;
pc.StartInfo.FileName = AppDir + "ffmpeg.exe";
pc.StartInfo.Arguments = ... some strings ...
pc.Exited += new EventHandler(handlerExit);
pc.Start();
// End Page
Response.Flush();
this.Context.ApplicationInstance.CompleteRequest();

void handlerExit(object sender, System.EventArgs e)
    {
            string[] files = Directory.GetFiles(vars["path"] ,vars["filein"] + "*");
            for (int i = 0; i < files.Length; i++)
            {
                File.Delete(files[i]);
            }
    }

the browser correct receive response when ffmpeg is still running, but ASPNET stop to respond to every subsequent requests. When process exit,the ASPNET Worker process start again to respond. I attempted to adjust process priority start option like AboveNormal or Idle but without success. Any ideas to manage this ?

alrama
  • 618
  • 11
  • 17

1 Answers1

1

This is due to session lock. Disable the session on the page you call that.

Reference:

jQuery Ajax calls to web service seem to be synchronous

Web app blocked while processing another web app on sharing same session

Replacing ASP.Net's session entirely

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • It seems to me you've catch the right point but adding EnableSessionState="false" directive to the Page that spawn the process isn't enough because wp continue to be blocked. Maybe I've to take a more deep look to ASPNET Session State. – alrama Jun 28 '12 at 12:20
  • I'm convinced that is not a Session State issue only. – alrama Jul 02 '12 at 09:17
  • @alrama Yes probably is not only session state issue, the next think is probably open threads that runs your code. – Aristos Jul 02 '12 at 09:37