开发者

How can I execute a specific chunk of code when my application crashes?

开发者 https://www.devze.com 2023-01-31 13:11 出处:网络
开发者_开发百科Is there a way that I can execute a specific chunk of code when my application crashes? (i.e. If my application crashes, I would like to safely close some streams) You can use AppDomain
开发者_开发百科

Is there a way that I can execute a specific chunk of code when my application crashes? (i.e. If my application crashes, I would like to safely close some streams)


You can use AppDomain.UnhandledException event.


Well. You should do it in a try-catch-finally block then.

Final block is what happens last when you catch an exception. Example

0

精彩评论

暂无评论...
验证码 换一张
取 消