Top "Idisposable" questions

IDisposable is an interface within the Microsoft .NET Framework's Base Class Library (BCL).

Struct and IDisposable

I wonder why does it not compile? public static void Main(string[] args) { using (MyStruct sss = new MyStruct()) { sss.s = "…

c# .net idisposable using
Calling Dispose() vs when an object goes out scope/method finishes

I have a method, which has a try/catch/finaly block inside. Within the try block, I declare SqlDataReader as …

c# idisposable using using-statement
C# Linq-to-Sql - Should DataContext be disposed using IDisposable

I have several methods that deal with DB and all of them start by calling FaierDbDataContext db = new FaierDbDataContext(); Since …

linq-to-sql datacontext idisposable
What is the correct way of adding thread-safety to an IDisposable object?

Imagine an implementation of the IDisposable interface, that has some public methods. If an instance of that type is shared …

c# .net thread-safety idisposable
Does foreach automatically call Dispose?

In C#, Does foreach automatically call Dispose on any object implementing IDisposable? http://msdn.microsoft.com/en-us/library/aa664754(v=…

c# foreach idisposable
Intercepting an exception inside IDisposable.Dispose

In the IDisposable.Dispose method is there a way to figure out if an exception is being thrown? using (MyWrapper …

c# .net idisposable
Correct way to close WCF 4 channels effectively

I am using the following ways to close the WCF 4 channels. Is this right way to do it? using (IService …

c# wcf idisposable wcf-4
Combining foreach and using

I'm iterating over a ManageObjectCollection.( which is part of WMI interface). However the important thing is, the following line of …

c# foreach idisposable using
C# conditional using block statement

I have the follow code but it is awkward. How could I better structure it? Do I have to make …

c# idisposable using-statement
Guidelines For Dispose() and Ninject

So, I have a method exposed from a WCF service as such: public GetAllCommentsResponse GetAllComments(GetAllCommentsRequest request) { var response = new …

c# .net garbage-collection ninject idisposable