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 ?