Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Here is small repro:
In case of Mono 4.2(+)(after referencesource import of TPL) it will output:
>"SynchronizationContext.Current is null"
But in case of Mono 4.0(-) it will output:
SynchronizationContext.Current should never be null on UI Thread.
Here is also question and answer on MSDN where answer says TPL team is aware of bug, but it's not clear if it was ever fixed(notice this was 2011).
Don't skip this link just because it says WCF, it's not related to WCF :).
Notice that I can't reproduce this on any version of .Net on Windows.
I've looked into this and it looks like the SynchronizationContext is indeed properly "flowed", even if never surfaced in the Current property.
This sample (https://gist.github.com/alexischr/7f0b71abbc452b828d15) demonstrates that TPL uses the correct SyncContext for continuations ( boo() will run within the context even when it's reported null).
The referencesource ExecutionContext code is very complex and I haven't figured out yet how to surface SyncCtx without breaking it.
I tried to reproduce with Mono 126.96.36.199 (2017-06/6425f06) but I didn't get the "SynchronizationContext.Current is null" message, so marking as fixed.