Results 1 to 3 of 3

Thread: Dispose and Finalize method

  1. #1
    Junior Member
    Join Date
    Dec 2009

    Dispose and Finalize method

    if we are writting dispose method, is it compulsary to write gc.suppressFinalise in dispose method? This needs to be written when we have finalizer in our class.

    Now if we do now write the finalise method, how will dispose method be called?

  2. #2
    Junior Member
    Join Date
    May 2010

    Re: Dispose and Finalize method

    As per my understanding to implement the Dispose method We need to implement the Idisposable interface.If we use GC.Supressfinalize() then it will prevent the CLR to automaticaly call the Finalize method at that perticular moment.
    But even after Finalize method will be called after some time by CLR garbage collector to make the memory free by removing the unrefferenced objects if still available.

  3. #3
    Junior Member
    Join Date
    Jul 2010

    Re: Dispose and Finalize method

    First lets talk about Finalize() which is called by GarbageCollector.The developer hasn't do anything with this one.If he doesn't wants to execute this method then he can call System.GC.SuppressFinalize() .

    Dispose() on the other hand can be handled by the developer to write his own custom statements or to dispose of instances of the objects for the classes he created while desigining the application. so he can write his own way of handling the code.

  4.  Sponsored Ads


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.