Article ID: 305368 - Last Review: December 6, 2006 - Revision: 2.3 How to wait for a shelled application to finish by using Visual Basic 2005 or Visual Basic .NETThis article was previously published under Q305368
For a Microsoft Visual C# .NET version of this article, see 305369
(http://support.microsoft.com/kb/305369/
)
.
For a Microsoft Visual C++
version of this article, see
307388
(http://support.microsoft.com/kb/307388/EN-US/
)
.
For a Microsoft Visual Basic 6.0 version of this article, see 129796
(http://support.microsoft.com/kb/129796/
)
.
On This PageSUMMARY This article demonstrates how to use the .NET Framework Process class to start another application from your code and have the
code wait for the other application to close before it continues. When the code waits for the application to finish, there are two options:
Requirements
Wait indefinitely for the shelled application to finishThe following code sample starts another application (in this case, Notepad) and waits indefinitely for the application to close.Provide a time-out for the shelled applicationThe following code sample sets a time-out for the shelled application. The time-out for this example is set to 5 seconds. You may want to adjust this number (which is calculated in milliseconds) for your testing.TroubleshootingSometimes it may be difficult to choose between these two options. The primary purpose of setting a time-out is to prevent your application from hanging because the other application has hung. Time-outs are better suited for a shelled application that performs background processing, in which the user may not know that the other application has stalled and does not have a convenient way to close it.REFERENCES For more information about the Process class, see the following .NET Framework Class Library
documentation: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessClassTopic.asp
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDiagnosticsProcessClassTopic.asp)
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
306394
(http://support.microsoft.com/kb/306394/
)
How to determine when a shelled process ends in Visual Basic .NET or in Visual Basic 2005
| Article Translations
Audio/Video Resources
|
Back to the top
