My WCF service is IDisposable
because it uses a ReadWriterLockSlim
. When I dispose both of them in the following method:
public void Dispose()
{
lockSlim.Dispose();
}
Some of the public methods are still running (or accepting new connections, I don't know), and it fires exceptions because of the attempts of using disposed objects (the lockSlim in this case). It would be nicer if, when stopping a Windows Service hosted WCF Service, the Dispose
method was called after stopping all running methods and closing it for new connections. But it seems that it must be done manually. There are any shortcuts or examples?