[Mono-dev] System.Net and SynchronizationContext
Edward Ned Harvey (mono)
edward.harvey.mono at clevertrove.com
Fri Mar 6 11:42:36 UTC 2015
> From: mono-devel-list-bounces at lists.ximian.com [mailto:mono-devel-list-
> bounces at lists.ximian.com] On Behalf Of Federico Di Gregorio
> I have discovered that the Mono implementation of WebClient doesn't
> behave as described in this MSDN article:
It seems, the class status page for WebClient indicates as you've said - is a known issue - Many of the Async methods are marked as broken or incomplete.
So the solution is to workaround until it's fixed.
> I can probably provide some patches but I don't know if there are plans
> to replace that code with the one MS open sourced.
That is the big operative question.
> As a side note, inspecting the code I found that in quite a lot of
> places Mono doesn't implement the "event handler" pattern correctly doing:
> if (Event != null)
> instead of:
> var e = Event;
> if (e != null)
I agree that the pattern you've suggested is the better pattern, to avoid NullReferenceException in a race condition. I don't see anything "official" out there suggesting this pattern; in fact, all the example code I see from msdn and elsewhere uses the former pattern. Your post is the first time I've heard of the new pattern, and I'm going to use it from now on. Hopefully nobody objects to the suggested new pattern, and hopefully those changes are acceptable, but if not, maybe you can find something official suggesting the new pattern.
More information about the Mono-devel-list