I like instantiating my WCF service clients within a using
block as it\'s pretty much the standard way to use resources that implement IDisposable
:
@Marc Gravell
Wouldn't it be OK to use this:
public static TResult Using(this T client, Func work)
where T : ICommunicationObject
{
try
{
var result = work(client);
client.Close();
return result;
}
catch (Exception e)
{
client.Abort();
throw;
}
}
Or, the same thing (Func
in case of Service
These would make returning variables easier.