From 8d0d644450b1ff0ea04add21dce9eb2d4a3fdb75 Mon Sep 17 00:00:00 2001 From: Glenn <5834289+glennawatson@users.noreply.github.com> Date: Tue, 15 Oct 2019 23:16:20 +1100 Subject: [PATCH] Update SingleWindowDispatcherScheduler.cs --- .../Platforms/uap/SingleWindowDispatcherScheduler.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs b/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs index 933b5857ac..da842f0538 100644 --- a/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs +++ b/src/ReactiveUI/Platforms/uap/SingleWindowDispatcherScheduler.cs @@ -150,7 +150,14 @@ void RaiseToDispatcher(object sender, object e) private IDisposable ScheduleOnDispatcherNow(TState state, Func action) { - Interlocked.CompareExchange(ref _dispatcher, CoreApplication.Views.FirstOrDefault()?.Dispatcher, null); + try + { + Interlocked.CompareExchange(ref _dispatcher, CoreApplication.Views.FirstOrDefault()?.Dispatcher, null); + } + catch (Exception ex) + { + // Ignore + } if (_dispatcher == null || _dispatcher.HasThreadAccess) {