diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props index ee48060e..9da485ef 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -1,7 +1,7 @@ Reactive.Bindings - 9.3.0 + 9.3.1 neuecc xin9le okazuki https://github.com/runceel/ReactiveProperty rx mvvm async rx-main reactive diff --git a/Source/ReactiveProperty.Platform.WPF/Schedulers/ReactivePropertyWpfScheduler.cs b/Source/ReactiveProperty.Platform.WPF/Schedulers/ReactivePropertyWpfScheduler.cs index 07083320..3583ed79 100644 --- a/Source/ReactiveProperty.Platform.WPF/Schedulers/ReactivePropertyWpfScheduler.cs +++ b/Source/ReactiveProperty.Platform.WPF/Schedulers/ReactivePropertyWpfScheduler.cs @@ -12,7 +12,6 @@ namespace Reactive.Bindings.Schedulers; public class ReactivePropertyWpfScheduler : LocalScheduler { private readonly Dispatcher _dispatcher; - private readonly DispatcherSynchronizationContext _context; /// /// Construct a scheduler from Dispatcher. @@ -21,7 +20,6 @@ public class ReactivePropertyWpfScheduler : LocalScheduler public ReactivePropertyWpfScheduler(Dispatcher dispatcher) { _dispatcher = dispatcher; - _context = new DispatcherSynchronizationContext(dispatcher); } /// @@ -40,18 +38,19 @@ public override IDisposable Schedule(TState state, Func - { - if (!d.IsDisposed) + _dispatcher.BeginInvoke(() => { - d.Disposable = action(this, state); - } - }); + if (!d.IsDisposed) + { + d.Disposable = action(this, state); + } + }, + DispatcherPriority.Normal); return d; } @@ -80,46 +79,5 @@ public override IDisposable Schedule(TState state, TimeSpan dueTime, Fun // Note that avoiding closure allocation here would introduce infinite generic recursion over the TState argument return DefaultScheduler.Instance.Schedule(state, dt, (_, state1) => Schedule(state1, action)); } -} -internal static class SynchronizationContextExtensions -{ - public static void PostWithStartComplete(this SynchronizationContext context, Action action, T state) - { - context.OperationStarted(); - context.Post( - o => - { - try - { - action((T)o!); - } - finally - { - context.OperationCompleted(); - } - }, - state - ); - } - - public static void PostWithStartComplete(this SynchronizationContext context, Action action) - { - context.OperationStarted(); - - context.Post( - _ => - { - try - { - action(); - } - finally - { - context.OperationCompleted(); - } - }, - null - ); - } }