using-statement

Returning IEnumerable with using

Interesting problem I ran across which makes total sense. I have a generic method like so: public TResult Run<TResult>(Func<SqlDataReader, TResult> resultDelegate) { TResult result; using (SqlDataReader reader = command.ExecuteReader()) // command is SqlCommand with attached SqlConnection { result = resultsDelegate(read...

using statement on IDisposable object - delay of calling Dispose method

As describe this article, about usage of using on IDisposable objects, it says one interesting words: ...using block, the Dispose method is automatically called sometime after the block ends. (It may not be immediate; it depends on the CLR.) Interesting here is "It may not be immediate; it depends on the CLR". Can anyone provide more...