Creating a modal process

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a managed application called MainApp.exe and another non-managed
application called OtherApp.exe. I want to launch OtherApp.exe from
MainApp.exe using System.Diagnostics.Process.Start("OtherApp.exe"). This
works fine. Here is the trick: I want OtherApp.exe to behave like a modal
dialog. In other words, I don't want the user to be able to return to
MainApp.exe until OtherApp.exe has closed.

Is there any way to accomplish this?

Thanks,
Joe
 
In other words, I don't want the user to be able to return to
MainApp.exe until OtherApp.exe has closed.

The logic I use for this is shown below. Otherapp will run without a new
console window, and mainapp reads otherapp's stdout. Trim this stuff out if
you want - the trick you need is p.WaitForExit().

Dim p As New System.Diagnostics.Process
Dim s As String
With p.StartInfo
.FileName = "otherapp.exe"
.Arguments = "whatever"
.UseShellExecute = False
.RedirectStandardError = True
.RedirectStandardInput = True
.RedirectStandardOutput = True
.WindowStyle = ProcessWindowStyle.Hidden
.CreateNoWindow = True
End With
Try
p.Start()
s = p.StandardOutput.ReadToEnd()
p.WaitForExit()
Catch ex As Exception
s = ex.ToString
End Try
 
Back
Top