I have a simple WCF duplex TCP service that I am trying to stop programmatically. If I don't have any connected users, ServiceHost.Close() is very quick but if I even have one connected user, I find the Close() function to take quite a bit of time, sometimes >30seconds. Is this usual behavior?
On the other hand, Abort() is almost instantaneous and I am tempted to use that instead.
It may be. The docs state that
The Close method allows any unfinished work to be completed before returning. For example, finish sending any buffered messages.
There is an overload to Close()
which takes a TimeSpan
(and throws
if the timespan is exceeded)
Abort()
looks like the best way to stop a WCF host without delay.