WCF and a winforms application and close
If I have a method in which I initialize a WC开发者_运维知识库F proxy and use it, do I also have to call the Close
method on the proxy before the method ends, or is this taken care of for me?
Close it. Why wait for .Net to do it when you don't know when that will happen for the entire life of the app.
Generally speaking, resources should automatically be closed once they are out of scope. However, it is usually clearer and more efficient to close it as soon as you don't need it any more. If it's an IDisposable
object, you can use a using block to make it simpler:
using (MyObj obj = new MyObj())
{
// do stuff here
}
// now its closed
精彩评论