如何将进程设置为Child我的应用程序 [英] How Do I Set A Process To Child My Application
本文介绍了如何将进程设置为Child我的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨恶魔
i有一个C#应用程序,
主要形式我打开计算器,
现在我想要关闭我的应用程序然后关闭计算器,
如何将calc设置为我的应用程序的子项?
感谢
hi fiends
i have a C# application ,
in main form i open calculator ,
now i want when close my application then close calculator ,
how can i set calc to child of my application ?
thankful
推荐答案
MSDN
轻轻提供代码示例: Process.Close方法 [ ^ ]。
MSDN
gently provide code samples: Process.Close Method[^].
这很复杂,因为如果计算器是你的应用程序的一部分,那么它将关闭当您的应用程序执行时 - 只有当您(例如)将Windows计算器作为一个进程(通过Process.Start)打开时才会出现问题,因为计算器是一个完全独立的应用程序,并且与任何应用程序无关在那个p oint。
你可以(如Wes建议的那样)保留你已经开始的进程列表,但坦率地说,作为用户,如果我是应用程序我可能会相当恼火使用封闭,因为不同的一个 - 如果我丢失了任何数据,我会跟在你的头上! :笑:
但这很简单: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.close(v = vs.110)的.aspx 一> [ ^ ]甚至给出了一个例子。
This is complicated, because if the calculator is part of your application, then it will close when your application does - it's only when you are (for example) opening Windows Calculator as a process (via Process.Start) that it becomes a problem, because the calculator is a completely separate application, and is not related to your app in any way at that point.
You can (as Wes suggests) keep a list of Processes you have started, but frankly as a user I'd probably be rather annoyed if applications I was using closed because a different one did - and if I lost any data as a result, I'd be after your head! :laugh:
But it's simple enough to do: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.close(v=vs.110).aspx[^] even gives an example.
这篇关于如何将进程设置为Child我的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文