You are developing an application by using C#.
The application includes an object that performs a long running process.
You need to ensure that the garbage collector does not release the object’s resources until the
process completes.
Which garbage collector method should you use?
A.
ReRegisterForFinalize()
B.
SuppressFinalize()
C.
Collect()
D.
WaitForFullGCApproach()
B
SuppressFinalize: Requests that the common language runtime not call the finalizer for the specified object.
WaitForFullGCApproach: Returns the status of a registered notification for determining whether a full, blocking garbage collection by the common language runtime is imminent.
20 new questions on the latest dump from March 2017.
http://optifiles.com/70483ProgrammingInC
In the book there was basically the same question and it said the answer was GC.Collect(). I’m confused :/
me too
B.
by calling SuppressFinalize, the object is placed in a list of objects that are marked as ready for finalization. The garbage collector calls the Finalize methods for the objects in this list and removes the entries from the list. This method blocks until all finalizers have run to completion.
dispose method can call teh suppressfinalize to tell GC not to call objects finalizer(destructor) and to let obj skip finalization queue.