Skip to content

Commit

Permalink
fix: Setting dispatcherqueue from current window
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Oct 27, 2023
1 parent dd09d20 commit f797a4d
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)}");
}
}
}
Expand Down

0 comments on commit f797a4d

Please sign in to comment.