From f797a4dd0158e215727c35034a40e67c767db861 Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Fri, 27 Oct 2023 15:30:58 +1100 Subject: [PATCH] fix: Setting dispatcherqueue from current window --- .../ClientHotReloadProcessor.MetadataUpdate.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs index 348807de4faf..c5374ced83a3 100644 --- a/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs +++ b/src/Uno.UI.RemoteControl/HotReload/ClientHotReloadProcessor.MetadataUpdate.cs @@ -355,20 +355,22 @@ public static void UpdateApplication(Type[] types) _log.Trace($"UpdateApplication (changed types: {string.Join(", ", types.Select(s => s.ToString()))})"); } - var dispatcherQueue = DispatcherQueue.GetForCurrentThread(); #if WINUI - if (dispatcherQueue is null) - { - dispatcherQueue = CurrentWindow?.DispatcherQueue; - } -#endif + var dispatcherQueue = CurrentWindow?.DispatcherQueue; if (dispatcherQueue is not null) { dispatcherQueue.TryEnqueue(async () => await ReloadWithUpdatedTypes(types)); } +#else + var dispatcher = CurrentWindow?.Dispatcher; + if (dispatcher is not null) + { + _ = dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () => await ReloadWithUpdatedTypes(types)); + } +#endif else if (_log.IsEnabled(LogLevel.Trace)) { - _log.Trace($"Unable to access DispatcherQueue in order to invoke {nameof(ReloadWithUpdatedTypes)}"); + _log.Trace($"Unable to access Dispatcher/DispatcherQueue in order to invoke {nameof(ReloadWithUpdatedTypes)}"); } } }