Skip to content

Commit

Permalink
[corlib] SynchronizationContext does not work on non-root AppDomain o…
Browse files Browse the repository at this point in the history
…n Android

AndroidEnvironment.GetDefaultSyncContext just crashes when called on an AppDomain which is not the root AppDomain. This started appearing with the mono:2018-02 integration during which mono@252d61d was introduced.

Fixes https://github.com/xamarin/xamarin-android/issues/1561\#issuecomment-381736716
  • Loading branch information
luhenry authored and monojenkins committed Apr 18, 2018
1 parent e03516d commit d03896e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mcs/class/corlib/System.Threading/WaitHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public abstract partial class WaitHandle
static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeout, bool hasThreadAffinity, bool exitContext)
{
bool release = false;
#if !MONODROID
var context = SynchronizationContext.Current;
#endif
try {
waitableSafeHandle.DangerousAddRef (ref release);

Expand All @@ -64,6 +66,7 @@ static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeou
SynchronizationAttribute.ExitContext ();
#endif

#if !MONODROID
// HACK: Documentation (and public posts by experts like Joe Duffy) suggests that
// users must first call SetWaitNotificationRequired to flag that a given synchronization
// context overrides .Wait. Because invoking the Wait method is somewhat expensive, we use
Expand All @@ -79,7 +82,9 @@ static int WaitOneNative (SafeHandle waitableSafeHandle, uint millisecondsTimeou
false,
(int)millisecondsTimeout
);
} else {
} else
#endif
{
unsafe {
IntPtr handle = waitableSafeHandle.DangerousGetHandle ();
return Wait_internal (&handle, 1, false, (int)millisecondsTimeout);
Expand Down

0 comments on commit d03896e

Please sign in to comment.