Article ID: 305369 - Last Review: July 16, 2008 - Revision: 3.0 How to wait for a shelled application to finish by using Visual C#
This article was previously published under Q305369 For a Microsoft Visual Basic .NET version of this article, see 305368
(http://support.microsoft.com/kb/305368/EN-US/
)
.
For a Microsoft Visual C++ .NET version of this article, see 307388 (http://support.microsoft.com/kb/307388/EN-US/ ) . This article refers to the following Microsoft .NET Framework Class Library namespace:
On This PageSUMMARY
This step-by-step article shows you 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
Include namespacesYou must import the namespace for the Process class before you run the examples that follow. Place the following line of code before the Namespace or Class declaration that contains the code sample: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 the 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 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 or does not have a convenient way to close it.REFERENCES
For more information about how to use an asynchronous method to accomplish this task, click the following article number to view the article in the Microsoft Knowledge Base:
304032
(http://support.microsoft.com/kb/304032/
)
How to determine when a shelled process ends in Visual C#
For more general information about Visual C#, visit the following Usenet Web site:microsoft.public.dotnet.languages.csharp
(http://go.microsoft.com/fwlink/?linkid=5217)
| Other Resources Other Support Sites
CommunityGet Help NowArticle Translations
|






Windows Live
Facebook
Twitter
Linkedin
Digg it
Yahoo
Delicious
StumbleUpon
Yammer
Reddit
Technorati
FriendFeed
Email
Back to the top
