From 774e1076c51ce4de31ccfa63efce01148a9a1969 Mon Sep 17 00:00:00 2001 From: Lluis Sanchez Date: Thu, 17 Sep 2015 15:34:55 +0200 Subject: 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. --- main/src/core/MonoDevelop.Core/MonoDevelop.Core/Runtime.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'main') 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 /// 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"); } -- cgit v1.2.3