I read the Wrox Professional C # 4 and .NET 4 chapter in the Memory Management and Pointers section, in particular, on how garbage collection works. NETWORK. It talked about the reason that "the garbage collector does not know how to free unmanaged resources (for example, file descriptors, network connections and database connections)", therefore such classes should either declare a destructor (aka "finalizer"), or implement IDisposable.
IDisposable
It seems that all of these examples of "unmanaged resources" are related to interacting with a system that is an integral part of the application and is not dependent on the .NET Framework. However, I'm not sure if this is the complete difference that is being made, therefore
You did it all:Managed resources are managed by the CLR, unmanaged resources are not. In other words: Managed resources live only in the .NET world, where unmanaged resources are in the normal Win32 world.
With managed resources (i.e. memory), you do not need to worry about what happens to them after you use them; The CLR will take care of this.
( : Windows, GDI, USER) , . , , , , , .
, .NET , ( dispose/finalize pattern) . , .
, -, .Net framework, . , . - P/Invoke. , .Net, .Net "", .
@supercat
.net-, .
, . . , , , , . , Brush, , , Dispose(). / , Dispose(). Dispose() , , , , .
Brush
Dispose()
, , CreateXYZ() Win32, , DestroyXYZ()/DeleteXYZ(), . , , Dispose/Finalize, . , , , .
CreateXYZ()
" " . " ". , :
, " " , , ( Finalize), , ( , ). " ", , - , , , , , , .
Please note that while unmanaged resources are often such as OS descriptors for files, GDI objects, etc., it is a mistake to think of them in such terms. It is possible to have unmanaged resources that do not have access to anything outside of .Net; An example of this is event handlers. A critical aspect of unmanaged resources is that they need to be cleaned, and failure to perform such a cleanup will have some undesirable consequences.