e101000

e101000

  • NA
  • 3
  • 0

Process.WaitForExit() not working?

Jun 2 2004 11:31 AM
have a ASP.NET form that starts an async method that loops through a list of executable files and starts them off In the button click I call my async method --------------------------------------------------------------------------------------------------------- startBtchRunD = new StartBatchRunDelegate(StartBatchRun); startBtchRunD.BeginInvoke(newBatchRunId,DBConnectionString,ExecutableDirectory,new AsyncCallback(this.GoDone),null); --------------------------------------------------------------------------------------------------------- My method has the following loop ---------------------------------------------------------------------------------------------------------- foreach(Executable exe in Executables) { procStartInfo = new ProcessStartInfo(@"c:\windows\system32\wscript.exe",exe.File); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; Process p = new Process(); p = Process.Start(procStartInfo); p.Start(); string output = p.StandardOutput.ReadToEnd(); p.WaitForExit(); } -------------------------------------------------------------------------------------------------------- For some reason the wait for exit doesn't seem to be doing anything. This loop doesn't wait at all. If I have 4 executables ".vbs" files, they all start pretty much at the same time. Any ideas on why this doesn't seem to be working would be helpful. I tried to run this from within a windows service and it had the same problem. I must be missing something.

Answers (1)