diff options
author | Lluis Sanchez <lluis@xamarin.com> | 2015-09-17 16:34:55 +0300 |
---|---|---|
committer | Lluis Sanchez <lluis@xamarin.com> | 2015-09-17 16:36:24 +0300 |
commit | 774e1076c51ce4de31ccfa63efce01148a9a1969 (patch) | |
tree | 37003692470f82adade29aa188fe3d6010533627 | |
parent | ef4b596fb14d5ef07961605445da796ad1bbc665 (diff) |
Fix incorrect UI thread assertion
The synchronization context of a thread may change, so when checking
if the context is the UI thread context, check the instance type,
not the instance.
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs index dc5f347be2..ee5ab67e85 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs @@ -424,7 +424,8 @@ namespace MonoDevelop.Core /// </summary> public static void AssertMainThread () { - if (SynchronizationContext.Current != MainSynchronizationContext) + // Compare types, because instances can change (using SynchronizationContext.CreateCopy). + if (SynchronizationContext.Current.GetType () != MainSynchronizationContext.GetType ()) throw new InvalidOperationException ("Operation not supported in background thread"); } |