
目前我有探险家开始然后我有动作将我的应用程序带到前面但探险家可能需要几秒钟才能开始,这会弄乱我的整个事件链.
这就是我目前正在做的事情:
Process process = new Process(); process.StartInfo.filename = environmentvariable + "\explorer.exe"; process.StartInfo.Arguments = !string.IsNullOrEmpty(this.uxMainFolder.Text) ? this.uxMainFolder.Text + "\" + path2 : Path.Combine("R:\Project",path2); try { process.Start(); this.windowstate = Formwindowstate.Minimized; this.Show(); this.windowstate = Formwindowstate.normal; } finally { process.dispose(); } 你可以解决这个问题的任何亮点将非常感激.
编辑:我正在寻找一些事件,我可以在加载资源管理器后调用topMost或我的最小化/显示/正常方法.
该程序生成一个项目目录,其中包含每个项目类型的所有必需文档,并在资源管理器中d出该目录.
对于想要一次创建10个或20个项目的用户来说,这意味着生活质量的改变.
解决方法 丑陋的方式Process.WaitForinputIDle()
从MSDN开始:
@H_301_26@Causes the Process component to wait indefinitely for the associated process to enter an IDle state. This overload applIEs only to processes with a user interface and,therefore,a message loop.
使用explorer.exe时,这很可能无法正常工作,因为此过程通常会生成子进程并立即死亡.
解决方法是启动进程,Sleep for say,250-500ms,然后使用一些godawful Hack找到新进程,然后在该进程上调用WaitForinputIDle.
替代
如果您愿意最小化explorer.exe,可以这样做:
processstartinfo psi = new processstartinfo();psi.filename = "explorer.exe";psi.Arguments = "/separate";psi.UseShellExecute = true;psi.windowstyle = Processwindowstyle.Minimized;Process.Start(psi);总结
以上是内存溢出为你收集整理的c# – 等待进程启动全部内容,希望文章能够帮你解决c# – 等待进程启动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)