本文介绍了如何知道 Process.Start 何时加载 winform?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 WindowsForm (c# 3.5) 中,点击一个按钮,使用 Process.Start() 启动另一个外部应用程序(也是 3.5),并了解它在我启动后何时可用.
I'm in a WindowsForm (c# 3.5) and on click of a button launch another external application (also 3.5) using Process.Start() and understand when it is available after i have launched it.
ProcessStartInfo psInfo = new ProcessStartInfo(@"MyApplication.exe"); psInfo.RedirectStandardOutput = true; psInfo.RedirectStandardError = true; psInfo.UseShellExecute = false; psInfo.CreateNoWindow = true; Process proc = Process.Start(psInfo); proc... IsFullyLoaded()?我该怎么做?
推荐答案要等待进程创建其表单,请调用 WaitForInputIdle 方法.
To wait for the process to create its form, call the WaitForInputIdle method.
要了解它是否准备就绪,请尝试以下操作:
To find out whether it's ready, try this:
bool isReady = proc.WaitForInputIdle(0);或者,或者,
bool isReady = (proc.MainWindowHandle != IntPtr.Zero);您还可以使用 MainWindowHandle 属性通过 SendMessage API 函数
You can also use the MainWindowHandle property to send messages to the form using the SendMessage API function
更多推荐
如何知道 Process.Start 何时加载 winform?
发布评论