My program need to occupy some resources.
I want it to release those resources before exit. It’s easy to achieve when the excutable exit normally.
However, what if the user open task manager in windows and kill the excutable? My destructors won’t get hit in this case.
Does anybody know a good parttern to solve this? (C#)
Thanks a lot,
You cannot handle the scenario if user kill the application forcefully. But you don’t have to worry about the resources. Windows will automatically free the resources acquired by your process when it is killed.