|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Creating a modal processI 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 The logic I use for this is shown below. Otherapp will run without a new > MainApp.exe until OtherApp.exe has closed. 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 Hi Joe,
Thanks for posting! As AMercer mentioned, the Process.WaitForExit method is appropriate for the current "trick". Just for your reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/ frlrfSystemDiagnosticsProcessClassWaitForExitTopic.asp Regards, Yuan Ren [MSFT] Microsoft Online Support
Other interesting topics
Browse for folders dialog
Why can't you inherit System.Windows.Forms.Form? Closing form causes validation hierarchical grid Explorer style interface DataGridview combobox column scrolling text Databinding Textbox on TabPage compact framework combo box Autoscroll jump when removing a control at run-time |
|||||||||||||||||||||||