Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. About Dispose method

About Dispose method

Scheduled Pinned Locked Moved C#
question
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I don't quite understand what dispose method exacly does. From manual I read that it "frees up ny ressources being used". But what happens to the object after calling dispose method ? Is it destroyer ? Also - is there any link between an object's destructor and dispose method ? Regards, Desmond

    M H J 3 Replies Last reply
    0
    • L Lost User

      I don't quite understand what dispose method exacly does. From manual I read that it "frees up ny ressources being used". But what happens to the object after calling dispose method ? Is it destroyer ? Also - is there any link between an object's destructor and dispose method ? Regards, Desmond

      M Offline
      M Offline
      Meysam Mahfouzi
      wrote on last edited by
      #2

      Lately, Heath[^] provided me a very cool link about this subject: http://www.albahari.com/value%20vs%20reference%20types.html[^] I hope it helps!


      Don't forget, that's

      Persian Gulf

      not Arabian gulf!


      Murphy:
      Click Here![^]


      I'm thirsty like sun, more landless than wind...

      1 Reply Last reply
      0
      • L Lost User

        I don't quite understand what dispose method exacly does. From manual I read that it "frees up ny ressources being used". But what happens to the object after calling dispose method ? Is it destroyer ? Also - is there any link between an object's destructor and dispose method ? Regards, Desmond

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        IDisposable.Dispose (you must implement IDisposable for this to be used correctly) is best used to free native resources (since many classes in .NET use native HANDLEs). You can also use it to dispose child objects and set references to null. This is not a destructor, though. In fact, many times when the Dispose method cleans-up the resources, it will tell the GC to not call the destructor since there's nothing left to do (be sure you clean-up all resources before doing so, though):

        public void Dispose()
        {
        // Clean up native resources and any managed resource you might have.
        GC.SuppressFinalize(this);
        }

        For a more thorough example, see the documentation for the GC.SuppressFinalize method in the .NET Framework SDK.

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        • L Lost User

          I don't quite understand what dispose method exacly does. From manual I read that it "frees up ny ressources being used". But what happens to the object after calling dispose method ? Is it destroyer ? Also - is there any link between an object's destructor and dispose method ? Regards, Desmond

          J Offline
          J Offline
          joan_fl
          wrote on last edited by
          #4

          there is a Garbage Colection 101 article on CodeProject here[^] ------------------------------- Joan MomComputerGeek.com

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups