From abfb168e50edc34f8d4f4042c754396eb88f0891 Mon Sep 17 00:00:00 2001 From: AlonAm Date: Tue, 19 Sep 2023 17:30:23 +0300 Subject: [PATCH] Update DIToolkitPackage.cs create and add commands on the main UI thread to support package background loading --- src/Core/Shared/DIToolkitPackage.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Core/Shared/DIToolkitPackage.cs b/src/Core/Shared/DIToolkitPackage.cs index c9f0d81..69a4dc5 100644 --- a/src/Core/Shared/DIToolkitPackage.cs +++ b/src/Core/Shared/DIToolkitPackage.cs @@ -54,6 +54,8 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke .Where(x => typeof(BaseDICommand).IsAssignableFrom(x.ImplementationType)) .ToList(); + await JoinableTaskFactory.SwitchToMainThreadAsync(); + foreach (var command in commands) { var baseCommandTypeGeneric = typeof(CommandWrapper<>).MakeGenericType(command.ImplementationType);