forum

Home / DeveloperSection / Forums / Capture console exit C#

Capture console exit C#

marcel ethan 3909 12-Dec-2013

I have a console application that contains quite a lot of threads. There are threads that monitor certain conditions and terminate the program if they are true. This termination can happen at any time.

I need an event that can be triggered when the program is closing so that I can cleanup all of the other threads and close all file handles and connections properly. I'm not sure if there is one already built into the .NET framework, so I'm asking before I write my own.

I was wondering if there was an event along the lines of:

MyConsoleProgram.OnExit += CleanupBeforeExit;


Please Help.

c# c# 
Updated on 12-Dec-2013

Can you answer this question?


Answer

1 Answers

Liked By