Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Closing multiple projects in Visual Studio

I have two projects running in Visual Studio but whenever I exit one the other keeps running. How can I close both?

Ps: I’m using Application.Exit() to close the first one

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

If you want to use Application.Exit() to close the first process, and you want to close the second process at the same time, try adding the following lines immediately before you call Application.Exit():


Process[] processes = Process.GetProcessesByName("SecondProcess");
processes[0].Kill();

where SecondProcess is the process name of your second process. (You will also need to add a using reference to System.Diagnostics.)

This code assumes exactly one such process will be running; if that’s not necessarily the case, you might need to do more.

Use with caution: killing a running process like this might not be advisable! Other methods are possible and probably better but without more information about your exact setup it’s hard to know which approach to suggest.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading