[Mono-dev] WeakReference problem
tobias.kaes at gmx.de
Wed Jan 29 22:00:02 UTC 2014
Hi, the generic WeakReference<T> for .NET 4.5 sometimes returns true
from TryGetTarget even though the target has been collected (the
out-value is correctly set to null). All my WeakReferences have been
initialized with non-null values.
Looking at the source at github I can imagine that there is a race
between the handle.IsAllocated check and the handle.Target retrieval,
but I'm no expert. Should I file a bug on that one? I'm not sure what
the expected behavior is since MSDN documentation of that method isn't
so great, but if the caller has to check the out-value against null
anyways, then the return value becomes kinda pointless in my opinion.
More information about the Mono-devel-list