如何使用 Process.WaitForExit [英] How to use Process.WaitForExit
本文介绍了如何使用 Process.WaitForExit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在调用一个有时"在 VB.NET 中工作的第三部分应用程序(它是一个自托管的 WCF).但有时第 3 方应用程序会永远挂起,因此我为其添加了 90 秒计时器.问题是,我怎么知道事情是否超时?
I'm calling a 3rd part app which 'sometimes' works in VB.NET (it's a self-hosted WCF). But sometimes the 3rd party app will hang forever, so I've added a 90-second timer to it. Problem is, how do I know if the thing timed out?
代码如下:
Dim MyProcess as System.Diagnostics.Process = System.Diagnostics.Process.Start(MyInfo)
MyProcess.WaitForExit(90000)
我想做的是这样的
If MyProcess.ExceededTimeout Then
MyFunction = False
Else
MyFunction = True
End If
有什么想法吗?
谢谢,
杰森
推荐答案
检查方法返回值 - http://msdn.microsoft.com/en-us/library/ty0d8k56.aspx - 如果调用超时,它将返回 False.
Check the method return value - http://msdn.microsoft.com/en-us/library/ty0d8k56.aspx - if the call timed out, it will return False.
这篇关于如何使用 Process.WaitForExit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文