From de871a7537d434af337c08423f8afcad262a074d Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 16 Apr 2016 21:05:47 +0300 Subject: [PATCH] Fix PerspexSynchronizationContext --- src/Perspex.Base/Threading/PerspexSynchronizationContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Perspex.Base/Threading/PerspexSynchronizationContext.cs b/src/Perspex.Base/Threading/PerspexSynchronizationContext.cs index 15941557d4..cd81496927 100644 --- a/src/Perspex.Base/Threading/PerspexSynchronizationContext.cs +++ b/src/Perspex.Base/Threading/PerspexSynchronizationContext.cs @@ -42,8 +42,10 @@ namespace Perspex.Threading /// public override void Send(SendOrPostCallback d, object state) { - // TODO: Add check for being on the main thread, we should invoke the method immediately in this case - Dispatcher.UIThread.InvokeTaskAsync(() => d(state)).Wait(); + if (Dispatcher.UIThread.CheckAccess()) + d(state); + else + Dispatcher.UIThread.InvokeTaskAsync(() => d(state)).Wait(); } } } \ No newline at end of file