I am trying to open a proxy on a thread (in background), the thread makes a new instance of the proxy, calls a method of the service and immediately after disposes the service.
All of this happens on a thread :
var background = new Thread(() =>
{
var proxy = new AssignmentSvcProxy(new EndpointAddress(worker.Address));
try
{
proxy.Channel.StartWork(workload);
proxy.Dispose();
}
catch (EndpointNotFoundException ex)
{
logService.Error(ex);
proxy.Dispose();
proxy = null;
}
catch (CommunicationException ex)
{
logService.Error(ex);
proxy.Dispose();
proxy = null;
}
catch (TimeoutException ex)
{
logService.Error(ex);
proxy.Dispose();
proxy = null;
}
catch (Exception ex)
{
logService.Error(ex);
proxy.Dispose();
proxy = null;
}
}) { IsBackground = true };
background.Start();
I keep seeing intermittent timeout issues happening even though I have set the timeout to max for CloseTimeout, OpenTimeout, ReceiveTimeout, SendTimeout.
I just want to make sure design wise this is not an issue i.e. opening a service on a thread and disposing it?
EDIT :
Proxy internally establishes a channel with custom binding on different endpoints for each thread.