This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 38599 - Regression: SynchronizationContext.Current returns wrong value in delegate run by SynchronizationContext.Send.
Summary: Regression: SynchronizationContext.Current returns wrong value in delegate ru...
Status: RESOLVED FIXED
Alias: None
Product: Class Libraries
Classification: Mono
Component: Windows.Forms (show other bugs)
Version: 4.2.0 (C6)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Marek Safar
URL:
Depends on:
Blocks:
 
Reported: 2016-02-09 22:24 UTC by Tom Hindle
Modified: 2016-02-22 15:36 UTC (History)
2 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test case showing regression. (1.11 KB, text/x-csharp)
2016-02-09 22:24 UTC, Tom Hindle
Details
Another example showing bug using System.Timers.Timer with SynchronizingObject set. (671 bytes, text/x-csharp)
2016-02-10 18:11 UTC, Tom Hindle
Details

Description Tom Hindle 2016-02-09 22:24:43 UTC
Created attachment 14973 [details]
Test case showing regression.

See attached test program:

SynchronizationContext uiSyncContext = ....;
uiSyncContext.Send((state) =>
{
  // This should be true.
  // SynchronizationContext.Current == uiSyncContext
  // In mono 4.2.1 SynchronizationContext.Current returns null.
};

The following is output of test program running on various systems.
Note for mono 4.2.1 the last line doesn't return the expected result.

Output on .net:

Runing on UI thread context = 'System.Windows.Forms.WindowsFormsSynchronizationContext' expected: WindowsFormsSynchronizationContext
Thread running context = '' expected: (null or NOT WindowsFormsSynchronizationContext)
Running on UI thread context = 'System.Windows.Forms.WindowsFormsSynchronizationContext' expected: WindowsFormsSynchronizationContext

Output on mono 3.2.8:

Runing on UI thread context = 'System.Windows.Forms.WindowsFormsSynchronizationContext' expected: WindowsFormsSynchronizationContext
Thread running context = '' expected: (null or NOT WindowsFormsSynchronizationContext)
Running on UI thread context = 'System.Windows.Forms.WindowsFormsSynchronizationContext' expected: WindowsFormsSynchronizationContext


Output on mono 4.2.1

Runing on UI thread context = 'System.Windows.Forms.WindowsFormsSynchronizationContext' expected: WindowsFormsSynchronizationContext
Thread running context = '' expected: (null or NOT WindowsFormsSynchronizationContext)
Running on UI thread context = '' expected: WindowsFormsSynchronizationContext
Comment 1 Tom Hindle 2016-02-10 18:11:21 UTC
Created attachment 14988 [details]
Another example showing bug using System.Timers.Timer with SynchronizingObject set.

f
Comment 2 Marek Safar 2016-02-10 19:30:57 UTC
Fixed in master and Mono 4.3.2
Comment 3 Tom Hindle 2016-02-22 15:36:19 UTC
commit for fix was d5a93b13bf47508173e512178f32abd1e8411b98.

Note You need to log in before you can comment on or make changes to this bug.