Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / February 2006

Tip: Looking for answers? Try searching our database.

Creating a modal process

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joe - 06 Feb 2006 21:29 GMT
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
AMercer - 07 Feb 2006 00:22 GMT
>  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
"Yuan Ren[MSFT]" - 07 Feb 2006 03:28 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.