Disposing


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Disposing

  1. #1
    Micki Guest

    Disposing



    Is disposing the same object several times just only stupid, or do it have
    some other side effects?

    Thanks,
    Micki

  2. #2
    Gregor R. Peisker Guest

    Re: Disposing

    Hi Micki,

    > Is disposing the same object several times just only stupid, or do it have
    > some other side effects?


    That would depend on its implementation. It shouldn't have side effects if
    the methods is carefully designed. Some classes have a "Disposed" property,
    but its purpose seems to be to let you find out if you can still use the
    object, rather than determining the need to dispose.

    But I'd try to avoid it in general.

    Regards,
    Gregor



  3. #3
    Craig Clearman Guest

    Re: Disposing

    Micki,

    >Is disposing the same object several times just only stupid, or do it have
    >some other side effects?


    You should only .Dispose your objects once: when all of the references
    are finished. If you .Dispose an object that is still valid and
    active, you may well introduce a bug in another part of your program,
    which is holding a reference to your object, and expecting it to be in
    a known state.

    Thus, you really do not want to replace all of your Set obj = Nothing
    calls with obj.Dispose. You need to make sure that nobody else is
    holding a reference to your object.

    Ciao, Craig


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center