Re: " //Clean Up managed resources " f&*ck



Koliber,

What this means is that if you the disposing parameter of the Dispose
method is true, then you want to call Dispose on any reference that you have
which implements IDisposable. Say your class had a SqlConnection that it
was holding onto. If the disposing parameter was true, then you would call
Dispose on the connection, otherwise, you would not.


--
- Nicholas Paldino [.NET/C# MVP]
- mvp@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"Koliber (js)" <profesor_kinbote@xxxxxxxxxxxxxx> wrote in message
news:1179506637.986623.183020@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
sorry for my not perfect english

i am really f&*ckin angry

in this common pattern about dispose:


//////////////////////////////////////////////////////////

Public class MyClass:IDisposable
{
private bool IsDisposed=false;
public void Dispose()
{
Dispose(true);
GC.SupressFinalize(this);
}


protected void Dispose(bool Diposing)
{
if(!IsDisposed)
{
if(Disposing)
{
//Clean Up managed resources
}
//Clean up unmanaged resources
}
IsDisposed=true;
}


~MyClass()
{
Dispose(false);
}

}
////////////////////////////

most of things are clear -
there are two ways of calling dispose - one from finalizer (only
unmanaged managed will free automatically
if i do understand) second by Dispose() (managed and unamanaged by
hand) BUT

what the hell " //Clean Up managed resources " mean

pozdrawiam (greetings)
C Kinbote



.



Relevant Pages

  • Re: Disposing managed resources
    ... That is, from the performance point of view, if you know that a big memory structure is not needed anymore but normally it would still be rooted, it may help GC to dispose it and release references early so that GC can, if it needs, to get more resources. ... Some classes implement IDisposable, and in some of those cases, there are managed resources that can be "released" using the Disposemethod of that interface. ... More typically, you would use IDisposable to dispose of a resource that is either unmanaged, or itself has unmanaged resources and thus implements IDisposable. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: memory&handles growth due to not disposing command?
    ... > This is the primary function of Dispose. ... > release managed resources when it is not called from within GC. ... Cleaning Up Unmanaged Resources and Implementing a Dispose Method. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Disposing managed resources
    ... Some classes implement IDisposable, and in some of those cases, there are managed resources that can be "released" using the Dispose() method of that interface. ... More typically, you would use IDisposable to dispose of a resource that is either unmanaged, or itself has unmanaged resources and thus implements IDisposable. ... It seems to me, however, that the author doesn't really understand the .NET memory model very well, nor does he really seem to understand the true purpose of IDisposable (and he also doesn't seem to ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: GC and dispose
    ... We often use the Dispose for cleaning managed resources ... UNMANAGED resources inside your classes get cleaned up. ...
    (microsoft.public.dotnet.framework)
  • Re: " //Clean Up managed resources " f&*ck
    ... What this means is that if you the disposing parameter of the Dispose ... Net says to me that SqlConnection is unmanaged resource (resource I ...
    (microsoft.public.dotnet.languages.csharp)