Top "Dispose" questions

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources

Should I dispose a Mutex?

I'm working on 2 Windows Services that have a common database which I want to lock (cross-process) with a system Mutex. …

c# mutex dispose cross-process
When do I need to use dispose() on graphics?

I'm learning to draw stuff in C# and I keep seeing recommendations to use dispose(), but I don't quite understand …

c# user-interface graphics dispose
Does one need to close both NetworkStream and TcpClient, or just TcpClient?

I'm reading the documentation on TcpClient.Close() and noticed this: Calling this method will eventually result in the close of …

c# dispose tcpclient networkstream
C# CA2000:Dispose objects before losing scope using FileStream/XmlTextReader

I have lots of code like this: FileStream fs = File.Open(@"C:\Temp\SNB-RSS.xml", FileMode.Open); using (XmlTextReader reader = …

c# dispose using ca2000 ca2202
return the variable used for using inside the using C#

I am returning the variable I am creating in a using statement inside the using statement (sounds funny): public DataTable …

c# dispose idisposable using using-statement
Using the Destructor/Dispose of the base class?

In C#, as mentioned in the Documentation, and this nice post's accepted answer, it's stated that classes don't inherit the …

c# dispose destructor idisposable finalizer
When is Dispose necessary?

When you have code like: Bitmap bmp = new Bitmap ( 100, 100 ); Graphics g = Graphics.FromImage ( bmp ); Pen p = new Pen ( Color.FromArgb ( 128, …

c# .net gdi+ dispose garbage-collection
Dispose/Close ExchangeService in C#?

I'm using the ExchangeService WebService API (Microsoft.Exchange.WebServices.Data) but I cannot find any Close or Dispose method. Is …

c# dispose exchangewebservices exchange-server-2007
What is IDisposable for?

If .NET has garbage collection then why do you have to explicitly call IDisposable?

c# garbage-collection dispose idisposable
How to dispose a Writeable Bitmap? (WPF)

Some time ago i posted a question related to a WriteableBitmap memory leak, and though I received wonderful tips related …

memory dispose writeablebitmap