检查过程是否在 VB.Net 中完成 [英] Check if process is done in VB.Net

查看:41
本文介绍了检查过程是否在 VB.Net 中完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有这个流程,我们想知道这个流程是否完成了?我们如何才能检查它是否已完成?

We have this process and we want to know if the process is done? How we'll be able to check if it is done?

代码如下:

Process.Start(filePath & ".bat", filePath.Substring(0, filePath.LastIndexOf("\")))

谢谢

推荐答案

在将 Process.Start 的返回值保存到变量后,您可以使用几个属性/方法:

There are several properties/methods you can use after you have saved the return value of Process.Start to a variable:

  • 如果您想等到进程退出,请使用 WaitForExit 方法.
  • 如果要检查进程是否仍在运行,请使用 HasExited 属性.
  • 如果在进程结束后需要退出代码,请使用 退出代码 属性.
  • If you want to wait until the Process has exited, use the WaitForExit method.
  • If you want to check whether the Process is still running, use the HasExited property.
  • If you need the exit code after the Process has ended, use the ExitCode property.

有关 Process 类及其功能的概述,请参阅此 链接.

For an overview of the Process class and its capabilities, see this link.

示例:

Dim p As Process = Process.Start(filePath & ".bat", filePath.Substring(0, filePath.LastIndexOf("\")))
p.WaitForExit()

这篇关于检查过程是否在 VB.Net 中完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆