Reputation: 4762
This method is defined within an ASP.NET Web application (.NET 4.5.2) that runs on IIS 6 or above:
public string GetValueFromProcess()
{
string val = string.Empty;
try
{
System.Diagnostics.Process p = System.Diagnostics.Process.Start(GetMyExeFilePath());
p.WaitForExit();
val = mainp.StandardOutput.ReadToEnd();
}
catch (Exception) { }
return val;
}
Will such a function be able to execute concurrently without problems or will I wrap it with a lock?
Obviously there are parameters that shall be passed along to the process but I removed that part for simplicity.
Upvotes: 0
Views: 46
Reputation: 842
The function will block the current request, waiting for "p.WaitForExit();" to complete. Concurrent requests will spawn multiple processes. You will also need to consider the IIS request script timeout setting which will throw a ThreadAbort exception.
Upvotes: 1