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 Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are sites? What are they used for?

2795


Which is best among dotnet and dotnet diploma? Friends Please answer this question as soon as possible.

1827


How do you create a new application partition

2002


Which is best insistute to learn IIS 6.0 and 7.0

2299


HOW TO USE FSMO ROLES IN FOREST.. MEANS IF WE HAVE A THREE DOAMINS IN FOREST .....THEY R HYD.COM(FIRST ONE....PRIMARY DOMAIN IN THE FOREST),BANG.COM (SECOND DOMAIN),CSD.COM(THIRD DOMAIN). I WANT TO IMPLEMENT FSMO ROLES IN THIRD DOMAIN HOW TO IMPLEMENT IT ...MEANS HOW TO CONNECT WITH DOAMIN AND WHAT ROLES WE IMPLEMENT..

2437






Hi can any one help me for 70-562 dumps?

2416


What are application partitions? When do I use them

1810


What is POST?

6693


Types of routing groups

2282


What do you do to install a new Windows 2003 R2 DC in a Windows 2003 AD?

1698


windows file/folder sharing ?

1940


is the cogent cyber solution trainig centre best for .net course?

2172


mcse 2003 to mcitp upgrade paper

2953


HI Guys...... Good day ahead How many sub domains can be added in exchange server means in a domain

2208


Can you connect Active Directory to other 3rd-party Directory Services? Name a few options.

2848