[Mono-dev] What will happen if Dispose() hangs?
Edward Ned Harvey (mono)
edward.harvey.mono at clevertrove.com
Tue Jan 27 17:56:41 UTC 2015
> From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] On Behalf Of Robert Jordan
> You may want to look up how a sane IDisposable pattern has to be
> sensibly implemented in .NET. You'll find out that Dispose()
> shouldn't be called from a finalizer.
Uhmm... You got that wrong. Here is the recommended pattern:
Basically, *always* call Dispose(false) from the finalizer, if present, but avoid having a finalizer unless you need one.
Fortunately, it looks like SslStream has no finalizer, so I guess the GC will never call any variant of SslStream.Dispose. So I guess it's no problem.
> A blocking finalizer will hang the GC, but it looks like SslStream is
> implementing finalization correctly:
Finalization seems to be correct. But Dispose hangs. Doesn't seem to be the fault of SslStream, but one of the dispose methods that gets called, either directly or indirectly, from the SslStream Dispose method.
More information about the Mono-devel-list