关闭另一个进程时,应用程序关闭 [英] Close another process when application is closing

查看:166
本文介绍了关闭另一个进程时,应用程序关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有它的工作过程中打开另一个WinForm的过程中一个C#WinForm应用程序。其他进程都有自己的UI。
当我关闭父应用程序,我想其他的应用程序被自动关闭。

I have a C# winform application that during its work opens another Winform process. The other process has UI of its own. When I close the parent application, I want the other application to be closed automatically.

我怎样才能做到这一点?

How can I achieve that?

感谢

推荐答案

如果您使用的是 Process.Process 还有就是 CloseMainWindow 方法。如果你坚持,你可以在以后使用它的对象的引用。

If you are using Process.Process there is the CloseMainWindow method. If you keep a reference to the object you can use it later.

下面是在的 MSDN

和相关代码:

// Close process by sending a close message to its main window.
myProcess.CloseMainWindow();
// Free resources associated with process.
myProcess.Close();

这篇关于关闭另一个进程时,应用程序关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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