wip
This commit is contained in:
@@ -40,11 +40,6 @@ public class ContentControlHandler :
|
||||
{
|
||||
activation.IsActive = false;
|
||||
}
|
||||
|
||||
if (content is IDisposable disposable)
|
||||
{
|
||||
disposable.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Toolkit.Foundation;
|
||||
|
||||
@@ -8,7 +9,7 @@ public static class IServiceCollectionExtensions
|
||||
{
|
||||
public static IServiceCollection AddWinUI(this IServiceCollection services)
|
||||
{
|
||||
services.AddTransient<IDispatcher, WinUIDispatcher>();
|
||||
services.AddSingleton<IDispatcher>(provider => new WinUIDispatcher(DispatcherQueue.GetForCurrentThread()));
|
||||
services.AddTransient<IDispatcherTimerFactory, DispatcherTimerFactory>();
|
||||
services.AddSingleton<IWindowRegistry, WindowRegistry>();
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ using Toolkit.Foundation;
|
||||
|
||||
namespace Toolkit.WinUI;
|
||||
|
||||
public class WinUIDispatcher :
|
||||
public class WinUIDispatcher(DispatcherQueue dispatcherQueue) :
|
||||
IDispatcher
|
||||
{
|
||||
public Task Invoke(Action action)
|
||||
{
|
||||
DispatcherQueue.GetForCurrentThread().TryEnqueue(action.Invoke);
|
||||
dispatcherQueue.TryEnqueue(action.Invoke);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user