Top "Dispose" questions

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

Is SqlCommand.Dispose() required if associated SqlConnection will be disposed?

I usually use code like this: using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConn"].ConnectionString)) { var command = connection.CreateCommand(); command.…

c# ado.net dispose sqlconnection sqlcommand
Dynamically create and remove a control from a form, many times

The below subroutine, when called using a mouse click, successfully creates and then removes a control. but it doesn't create …

vb.net controls dispose dynamically-generated
What happens if i return before the end of using statement? Will the dispose be called?

I've the following code using(MemoryStream ms = new MemoryStream()) { //code return 0; } The dispose() method is called at the end of …

c# .net dispose idisposable using-statement
Aforge.net Camera Capture & Save image to directory

everyone. I have been stuck here dealing with this bugs for days, but I still couldn't figure it out. My …

c# debugging dispose aforge
What is the difference between finalize and dispose in .net?

Possible Duplicate: Finalize vs Dispose Hi, Recently I was quizzed in an interview about finalize and dispose. When is each …

.net garbage-collection dispose finalize
How do I prevent a form object from disposing on close?

I am using an MDIParent Form. When I close its child, the object of the child disposes. Is there a …

c# winforms dispose formclosing
Is it considered acceptable to not call Dispose() on a TPL Task object?

I want to trigger a task to run on a background thread. I don't want to wait on the tasks …

c# .net multithreading dispose task-parallel-library
How to find out an object has disposed?

I have a multi-threaded application and a CancellationToken is used as a shared object. Every thread can trigger it to …

c# dispose cancellationtokensource
using on SQLDataReader

I know I asked a related question earlier. I just had another thought. using (SqlConnection conn = new SqlConnection('blah blah')) { …

c# dispose sqldatareader using-statement
Should I manually dispose the socket after closing it?

Should I still call Dispose() on my socket after closing it? For example: mySocket.Shutdown(SocketShutdown.Both); mySocket.Close(); mySocket.…

c# sockets dispose