You work as the application developer at Certkiller .com.
You create a new class that
uses unmanaged resources, but which still has references to
managed resources on
other objects.
You want users of the new class to be able to explicitly
release resources when the
class instance is no longer required.
What should you do next?
Choose the three actions which you should perform. Each
correct answer presents
only part of the complete solution.
Answer / gaaa
A. Define the existing class so that it inherits from the
WeakReference class.
B. Define the existing class so that it applies the
IDisposable interface.
C. Create a new class destructor which calls methods on
other objects to release the
managed resources.
D. Create a new class destructor that releases the unmanaged
resources.
E. Create a new Dispose method that calls System.GC.Collect
to force garbage
collection.
F. Create a new Dispose method that releases unmanaged
resources and which also calls
methods on other objects to release the managed resources.
Answer: B,D,F
Explanation:
It is necessary to implement the IDisposable interface if
you need to release unmanaged
resources or want explicit control of the life of managed
resources. A class destructor
should be created to release the unmanaged resources and
this should be called from within the Dispose method. The
dispose method should also release the managed
resources.
Inheriting from WeakReference would result in the garbage
collector releasing resources
even though there may be valid references.
The managed resources should be released in the Dispose method.
System.GC.Collect could be used, however it is more
efficient to manually release the
managed resources. The GC incurs overhead and may have only
recently been called
anyway. The question states resources should be released
explicitly.
Is This Answer Correct ? | 3 Yes | 0 No |
What is the difference between joining and blending in Tableau?
How Replication Works
A Computer gets shutdown as soon as it is plugged in with a cracking noise what is the reason and how to recover it and bring to normal state?brief description what are the necessary steps taken to bring the system up to normal state?
You work as the application developer at Certkiller .com. You are working on an application and want to use platform invoke services to call an unmanaged function from managed code. How will you accomplish the task?
Where is the AD database held? What other folders are related to AD?
How do you restore Active Directory?
What is the Difference between Fat32 and NTFS partion?
Whats Main Deference in Win XP and Win vista?
4 Answers PCS, Unique Software Systems,
What do you do to install a new Windows 2003 R2 DC in a Windows 2003 AD?
What is the function of Domain Partition?
Hi, I am gayathri.Could anyone of u who see this question plz answer and help me in this regard.I want to do .NET certification...I want to know the centres which offers this certification.
what is the process to check server health