Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
[no name] 4-Jul-14 4:17am    
Keep a list of process "children" and when your application closes, close the children.

MSDN gently provide code samples: Process.Close Method[^].
 
Share this answer
 
v2
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900