I've wrapped my wcf client in a IDisposable wrapper and everything appears to work correctly, I have a test case that runs this x times after around 10 times I start to get timeout's
The calling code has the helper wrapped in a using statement, so tbh I'm at a bit of a loss
Anyone shed any light on this?
public class CrmServiceHelper : IDisposable
{
private CrmServices.CRMServicesClient client;
public CrmServices.CRMServicesClient GetClient
{
get
{
lock (this)
{
if (client == null)
client = new CrmServices.CRMServicesClient();
}
return client;
}
}
public void Dispose()
{
try
{
client.Close();
}
catch (CommunicationException ex)
{
client.Abort();
}
catch (TimeoutException ex)
{
client.Abort();
}
}
}
Sample usage code:
using (CrmServiceHelper client = new CrmServiceHelper())
{
AListReponse resp = client.GetClient.GetAList(companyId);
if ((resp != null) && (resp.AList != null))
{
return resp.AList ;
}
else
{
return null;
}
}
Service config