Clean up resources

Posted on 2006-04-04
Medium Priority
Last Modified: 2010-04-16
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

    camera = new Camera();


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?
Question by:AlexFM
  • 3
  • 2
LVL 48

Author Comment

ID: 16370715
Camera class has destructor which calls ShutDown, but this destructor is not called in the case of exception.
LVL 12

Expert Comment

ID: 16370775
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
LVL 48

Author Comment

ID: 16370982
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.
LVL 12

Accepted Solution

gbzhhu earned 2000 total points
ID: 16371344
Have a read at this it may help


Does the app actually crash when you have an unhandled exception? or does it continue
LVL 48

Author Comment

ID: 16371675
It looks exactly like my case. The bad news are that there is nothing to do with this.

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question