Examples of unmanaged resources include operating system handles, file
handles, memory allocated by a direct call to a Win32 API, etc.
Unmanaged resources usually come into play when you use the interop
features provided by the framework.
The pattern dictates that disposing == true when called from the public
Dispose method. That means you (the developer) have chosen to
deterministicly dispose the object either directly by calling Dispose
or indirectly by using on of the C# constructs that automatically
generates the call to Dispose. If disposing == false then that means
the object is being disposed by the GC through the Finalize
(destructor) method.
The reason the pattern has two separate branches is because managed
resources cannot be touched when disposing == false since the GC may
have already disposed them.
Brian
DaTurk wrote:
Hi,
I'm implementing the Idisposable pattern and am wondering what the
difference it between managed, and unmanaged resources?
http://msdn2.microsoft.com/en-us/library/fs2xkftw.aspx
in the code snippet where it's overloading the Dispose method it
disposes of managed and unmanaged resources if disposing == true, and
only unmanaged resources if disposing is false. I'm not sure I
completely understand. Thank you in advance.