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.
// Correct output is 123 (.NET)
// Wrong output is 132 (Mono)
// There should be no Context.Post if context in the end of called async method is same as the context in caller method
private async void Form1_Load(object sender, EventArgs e)
private async Task Wait()
BeginInvoke((Action) (() => Console.Write(3)));
I don't have simple way to test it as Winforms does not initialise for me but Mono 3.2.7 should have this issue fixed. Please reopen the bug report if it does not resolve your issue.
Still reproduces on 3.4.0
I think your code can produce both 123 and 132 or even 312 it depends on how fast is BeginInvoke.
This is how SyncContexts work. It is a message loop with sequential execution of delegates. There is no non-determinism in single loop iteration.
Or it can be that BeginInvoke inlines execution of Delegate and does it in current iteration instead of posting it to next one.
I'll check this right now.
Created attachment 6637 [details]
Here is a repro without WindowsForms/BeginInvoke.
A simple console app with custom message loop.
Result is the same.
Fixed in master
Thanks for the test case!
I have checked this issue on Windows and after running attached project in comment 6, I am getting output 123.
Hence closing this issue.
Environment info :
=== Xamarin Studio ===
Version 5.1 (build 302)
Installation UUID: 3b924754-5196-440a-b42b-05ebb3a3082e
Microsoft .NET 4.0.30319.18408
GTK+ 2.24.22 (MS-Windows theme)
=== Xamarin.Android ===
Version: 4.13.0 (Enterprise Edition)
Android SDK: E:\AndroidSDK
Supported Android versions:
1.6 (API level 4)
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
3.2 (API level 13)
4.0 (API level 14)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
Java SDK: C:\Program Files\Java\jdk1.6.0_31
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode, sharing)
=== Build Information ===
Release ID: 501000302
Git revision: 37edec4110ed93f02581f1331d2ff5b38f9a3aa9
Build date: 2014-05-30 12:45:30-04
Xamarin addins: b4105598b2afb41dac2f91a523ce94dbb3f1efdf
=== Operating System ===