How can you start the process with asp.net without interfering with the website?

We have an asp.net application that can create .air files. To do this, we use the following code:

System.Diagnostics.Process process = new System.Diagnostics.Process();

//process.StartInfo.FileName = strBatchFile;
if (File.Exists(@"C:\Program Files\Java\jre6\bin\java.exe"))
{
    process.StartInfo.FileName = @"C:\Program Files\Java\jre6\bin\java.exe";
}
else
{
    process.StartInfo.FileName = @"C:\Program Files (x86)\Java\jre6\bin\java.exe";
}
process.StartInfo.Arguments = GetArguments();
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.UseShellExecute = false;
process.PriorityClass = ProcessPriorityClass.Idle;

process.Start();

string strOutput = process.StandardOutput.ReadToEnd();
string strError = process.StandardError.ReadToEnd();

HttpContext.Current.Response.Write(strOutput + "<p>" + strError + "</p>");

process.WaitForExit();

Well, the problem is that sometimes the server processor reaches 100%, forcing the application to run very slowly and even lose sessions (we think this is a problem).

Is there any other solution on how to create air files or run an external process without interfering with the asp.net application?

Cheers, M.

+3
source share
1 answer

: process.WaitForExit();, . IPC (Inter Process Communication, , , ), , .

+5

Source: https://habr.com/ru/post/1748828/


All Articles