I have a WCF service that I consume in my code and generated as a ChannelFactory class. I know that the proper way to consume the WCF is to create the ChannelFactory (let's call this AwesomeClient), do the work, then call Close() on it. Here's my snippet:
public static void DoSomething()
{
var client = new AwesomeClient();
client.DoSomethingAwesome();
client.Close();
}
However, I am expecting that DoSomething will be called quite frequently (say 10 times a minute?), so the advice I have gotten is to instantiate the ChannelFactory as a static instance, and always reuse the same instance, and never having to Close it (because this is 'cheaper' than always recreating the ChannelFactory and then closing it).
I'm here for a second opinion, can anyone tell me why not calling Close and reusing the static instance is a good idea? Or should I just stick with recreating the ChannelFactory and Close()-ing it for every call?