关于表单加载事件中的process.start方法 [英] about process.start method in form load event

查看:70
本文介绍了关于表单加载事件中的process.start方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vb.net中编写了一个窗口表单应用程序,在该应用程序表单加载事件中,我尝试启动另外三个表单应用程序(exe).因此,当我运行我的应用程序时,我的表单加载事件在这三个exe文件之前完成start.so我的问题是我如何在一段时间内保持或暂停表单加载事件,以便启动三个exe文件?

我的代码在这里...

i wrote an window form application in vb.net.in that application form load event i try to start three another form application(exe).so when i run my application my form load event is complete before that three exe start.so my question is how i hold or pause my form load event for some time so that three exe will be start??

my code is here...

form1_load()
{
   system.diagnostic.process.start("first.exe")
   system.diagnostic.process.start("second.exe")  
   system.diagnostic.process.start("third.exe")    
}


我也尝试在启动过程调用中尝试thread.sleep(),但是失败了.


i also tried thread.sleep() among start process call but it is failed.

推荐答案

将Process.Start指令从Form.Load事件移动到Form构造函数-您通过检查调用Process.GetProcessByName并确保它们都在其中,还可以阻止构造函数完成其他应用程序的运行.
Move the Process.Start instructions from the Form.Load event to the Form constructor - you could also hold your constructor from completing until the other apps are running, by check calling Process.GetProcessByName and ensuring they are all there.


取决于您正在启动的进程,您也许可以做这样的事情

Depending on the processes you are starting you might be able to do something like this

System.Diagnostics.Process proc = System.Diagnostics.Process.Start("name.exe");
proc.WaitForInputIdle();



WaitForInputIdle(int timeout)也有一个重载,因此它只会等待很长时间然后返回.



There is also an overload for WaitForInputIdle(int timeout) so it will only wait so long and then return.


这篇关于关于表单加载事件中的process.start方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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