Click here to Skip to main content
15,893,508 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
lmoelleb24-Jan-07 0:20
lmoelleb24-Jan-07 0:20 
GeneralRe: Is .Net 2.0 is backward compatible with .Net 1.1? Pin
Rob Graham24-Jan-07 10:23
Rob Graham24-Jan-07 10:23 
QuestionUsing BindingSource to edit stuff in a DataGridView Pin
Heavy Storm23-Jan-07 10:00
Heavy Storm23-Jan-07 10:00 
AnswerRe: Using BindingSource to edit stuff in a DataGridView Pin
Robert Rohde23-Jan-07 21:51
Robert Rohde23-Jan-07 21:51 
QuestionHandling Dispose when using unmanaged code Pin
AlexZieg7123-Jan-07 8:30
AlexZieg7123-Jan-07 8:30 
AnswerRe: Handling Dispose when using unmanaged code Pin
Dan Neely23-Jan-07 9:04
Dan Neely23-Jan-07 9:04 
AnswerRe: Handling Dispose when using unmanaged code Pin
Guffa23-Jan-07 11:37
Guffa23-Jan-07 11:37 
GeneralRe: Handling Dispose when using unmanaged code Pin
Tim Paaschen23-Jan-07 19:54
Tim Paaschen23-Jan-07 19:54 
Typically I use some code like this:
class MyClass : IDisposable
	private bool _isDisposed = false;

	~MyClass ()
	{
		Dispose( false );
	}

	public void Dispose()
	{
		Dispose( true );
		GC.SuppressFinalize( this );
	}

	protected virtual void Dispose( bool disposing )
	{
		if( !this._isDisposed )
		{
			// release unmanaged resources here

			if( disposing )
			{
				// release local managed resources here
			}
			this._isDisposed = true;
		}
	}
}

If Dispose() is not called, the Finalizer will do the cleanup.
Multiple calls to Dispose() do no harm.
There is just one method for cleanup to maintain [Dispose( bool disposing )].
And this method can be extended by derived classes.

As Guffa already pointed out, the interface IDisposable should only be used, if the classes uses unmanaged resources.


Regards,
Tim

GeneralRe: Handling Dispose when using unmanaged code Pin
Colin Angus Mackay24-Jan-07 22:16
Colin Angus Mackay24-Jan-07 22:16 
AnswerRe: Handling Dispose when using unmanaged code Pin
Scott Dorman28-Jan-07 6:53
professionalScott Dorman28-Jan-07 6:53 
QuestionCalculating Object Memmory Usage Pin
MikeMarq23-Jan-07 8:04
MikeMarq23-Jan-07 8:04 
AnswerRe: Calculating Object Memmory Usage Pin
Dave Kreskowiak23-Jan-07 8:44
mveDave Kreskowiak23-Jan-07 8:44 
GeneralRe: Calculating Object Memmory Usage Pin
MikeMarq24-Jan-07 9:53
MikeMarq24-Jan-07 9:53 
QuestionCan I customize the paper size and print a document directly Pin
indian14323-Jan-07 1:13
indian14323-Jan-07 1:13 
AnswerRe: Can I customize the paper size and print a document directly Pin
Dave Kreskowiak23-Jan-07 2:04
mveDave Kreskowiak23-Jan-07 2:04 
GeneralRe: Can I customize the paper size and print a document directly Pin
indian14323-Jan-07 2:14
indian14323-Jan-07 2:14 
GeneralRe: Can I customize the paper size and print a document directly Pin
Dave Kreskowiak23-Jan-07 5:31
mveDave Kreskowiak23-Jan-07 5:31 
GeneralRe: Can I customize the paper size and print a document directly Pin
indian14329-Jan-07 1:28
indian14329-Jan-07 1:28 
Questionwana buit an email clinet using a third party email server?? Pin
Saira Tanwir22-Jan-07 23:09
Saira Tanwir22-Jan-07 23:09 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
indian14322-Jan-07 23:24
indian14322-Jan-07 23:24 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
Guffa23-Jan-07 0:05
Guffa23-Jan-07 0:05 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
indian14323-Jan-07 1:07
indian14323-Jan-07 1:07 
AnswerRe: wana buit an email clinet using a third party email server?? Pin
indian14323-Jan-07 22:05
indian14323-Jan-07 22:05 
Questionproblems with permission?? Pin
spell12822-Jan-07 14:50
spell12822-Jan-07 14:50 
AnswerRe: problems with permission?? Pin
Heavy Storm23-Jan-07 10:11
Heavy Storm23-Jan-07 10:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.