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

Posted by Sem Dendoncker on Stack Overflow See other posts from Stack Overflow or by Sem Dendoncker
Published on 2010-06-07T11:28:05Z Indexed on 2010/06/07 11:32 UTC
Read the original article Hit count: 314

Filed under:
|
|
|

Hi,

We have an asp.net application that is able to 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 now is that sometimes the cpu of the server is reaching 100% causing the application to run very slow and even lose sessions (we think this is the problem).

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

Cheers, M.

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET