none
Disposing Unmanaged Resources RRS feed

  • Question

  • Hi All,

    I have used unmanaged resources in my class. Is there a way to disponse unmanaged resource in the class?

    Thanks in advance..

     

     

     

     

    Tuesday, June 29, 2010 11:07 AM

Answers

  • It would be helpful if responders knew what language you are using and what kind of resource you have included in your class.

    In very general terms, including a destructor to deal with the unmanaged resource might be one approach.

     

    • Marked as answer by eryang Monday, July 5, 2010 2:23 AM
    Tuesday, June 29, 2010 12:09 PM
  • To extend the comment of pvdg42, have a look here IDisposable
    • Marked as answer by eryang Monday, July 5, 2010 2:23 AM
    Tuesday, June 29, 2010 12:32 PM

All replies

  • It would be helpful if responders knew what language you are using and what kind of resource you have included in your class.

    In very general terms, including a destructor to deal with the unmanaged resource might be one approach.

     

    • Marked as answer by eryang Monday, July 5, 2010 2:23 AM
    Tuesday, June 29, 2010 12:09 PM
  • To extend the comment of pvdg42, have a look here IDisposable
    • Marked as answer by eryang Monday, July 5, 2010 2:23 AM
    Tuesday, June 29, 2010 12:32 PM
  •  

    A better understanding of .NET GC can help you to use either Finalize method or IDispose interface more efficiently, you may want to have a look at this article.

     

    By the way, the 'Automatic Memory Management' chapter of 'CLR via C#' has a detail discussion on this topic.


    Sincerely,
    Eric
    MSDN Subscriber Support in Forum
    If you have any feedback of our support, please contact msdnmg@microsoft.com.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Wednesday, June 30, 2010 3:46 AM