如何知道 Process.Start 何时加载 winform?

编程入门 行业动态 更新时间:2024-10-10 21:22:33
本文介绍了如何知道 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?

本文发布于:2023-11-06 08:34:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1563205.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   Process   Start   winform

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!