S
SpotNet
Hi NewsGroup,
Just got a hold of disposing and finalisers (destructors) on how to
effictively use them and understand what's going on with them, with great
thanks to this new group (thanks all). I would like to ask in when should
the disposed event be utilised for components\classes that offer them? Any
context for example;
Public Class Jet40Connection: IDisposable
{
private OleDbConnection jetconnection = null;
private bool isdisposed = false;
public Jet40Connection()
{
jetconnection = new OleDbConnection();
jetconnection.Disposed += new EventHandler(jetconnection_Disposed);
//Maybe I want this event...
}
public void Dispose()
{
this.Dispose(true);
GC.SupressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!isdisposed)
{
if (disposing)
{
//-----and the rest of it, close the connection, release it,
etc
}
}
}
private void jetconnection_Disposed(object sender, EventArgs e)
{
// ??????????????????????
}
~Jet40Connection()
{
this.Dispose(false)
}
}
Not only specifically to this example, what code would the _Disposed run if
it were implemented?
Many thanks and regards,
SpotNet
Just got a hold of disposing and finalisers (destructors) on how to
effictively use them and understand what's going on with them, with great
thanks to this new group (thanks all). I would like to ask in when should
the disposed event be utilised for components\classes that offer them? Any
context for example;
Public Class Jet40Connection: IDisposable
{
private OleDbConnection jetconnection = null;
private bool isdisposed = false;
public Jet40Connection()
{
jetconnection = new OleDbConnection();
jetconnection.Disposed += new EventHandler(jetconnection_Disposed);
//Maybe I want this event...
}
public void Dispose()
{
this.Dispose(true);
GC.SupressFinalize(this);
}
private void Dispose(bool disposing)
{
if (!isdisposed)
{
if (disposing)
{
//-----and the rest of it, close the connection, release it,
etc
}
}
}
private void jetconnection_Disposed(object sender, EventArgs e)
{
// ??????????????????????
}
~Jet40Connection()
{
this.Dispose(false)
}
}
Not only specifically to this example, what code would the _Disposed run if
it were implemented?
Many thanks and regards,
SpotNet