AlexFM
asked on
Clean up resources
I have C# Windows Forms application which works with C++/CLI Library. Library class works with camera and has clean-up function ShutDown. Wnen C# client exits, it calls ShutDown function and all works OK:
Camera camera; // form class member
Form_Load:
camera = new Camera();
Form_Closing:
camera.ShutDown();
But when program has unhandled exception, camera.ShutDown function is not called. Result of this is that process remains active and must be killed from Task Manager. How can I call this function in any case?
Camera camera; // form class member
Form_Load:
camera = new Camera();
Form_Closing:
camera.ShutDown();
But when program has unhandled exception, camera.ShutDown function is not called. Result of this is that process remains active and must be killed from Task Manager. How can I call this function in any case?
I think you have to handle yourexceptions with try catch finally block. In the case of unhandled exception i don't think anything gets called
ASKER
I don't want to handle all exceptions, I handle only exceptions which I expect to happen. Bugs in the program must remain unhandled. My problem is that class instance is not destroyed after unhandled exception.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It looks exactly like my case. The bad news are that there is nothing to do with this.
ASKER