Release resources when stop debugging

允我心安 提交于 2020-01-11 12:16:58

问题


I use Visual Studio 2005 & C#. In my FormClosing event I release some resources, that my application uses. But when I debug it and decide to stop (Stop debugging), than FormClosing event doesn't fire and my resources aren't properly released.

How can I avoid this?


回答1:


If you by "resources" mean things like open handles and allocated memory, you shouldn't worry. The OS will release this as the process terminates.

If you mean things like temporary files, registry keys, or other things that are committed to disk that you want to clean up after yourself, I'm afraid you won't be able to catch that when terminating the program, and will have to clean it up manually or on next start. To my knowledge, at least. :)



来源:https://stackoverflow.com/questions/1605752/release-resources-when-stop-debugging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!