Skip to content

Commit

Permalink
Release v9.3.1 (#437)
Browse files Browse the repository at this point in the history
* Update dotnet-core-unit-testing.yml

* ReactivePropertyWpfScheduler throws StackOverflowException. (#436)

* dispatch to ImmediateScheduler
* Incrment version number

* Update dotnet-core-unit-testing.yml
  • Loading branch information
runceel authored Aug 11, 2023
1 parent a9cb8ff commit ba99109
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<RootNamespace>Reactive.Bindings</RootNamespace>
<Version>9.3.0</Version>
<Version>9.3.1</Version>
<Authors>neuecc xin9le okazuki</Authors>
<PackageProjectUrl>https://github.com/runceel/ReactiveProperty</PackageProjectUrl>
<PackageTags>rx mvvm async rx-main reactive</PackageTags>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace Reactive.Bindings.Schedulers;
public class ReactivePropertyWpfScheduler : LocalScheduler
{
private readonly Dispatcher _dispatcher;
private readonly DispatcherSynchronizationContext _context;

/// <summary>
/// Construct a scheduler from Dispatcher.
Expand All @@ -21,7 +20,6 @@ public class ReactivePropertyWpfScheduler : LocalScheduler
public ReactivePropertyWpfScheduler(Dispatcher dispatcher)
{
_dispatcher = dispatcher;
_context = new DispatcherSynchronizationContext(dispatcher);
}

/// <summary>
Expand All @@ -40,18 +38,19 @@ public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TSta

if (_dispatcher.CheckAccess())
{
return action(this, state);
return ImmediateScheduler.Instance.Schedule(state, action);
}

var d = new SingleAssignmentDisposable();

_context.PostWithStartComplete(() =>
{
if (!d.IsDisposed)
_dispatcher.BeginInvoke(() =>
{
d.Disposable = action(this, state);
}
});
if (!d.IsDisposed)
{
d.Disposable = action(this, state);
}
},
DispatcherPriority.Normal);

return d;
}
Expand Down Expand Up @@ -80,46 +79,5 @@ public override IDisposable Schedule<TState>(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<T>(this SynchronizationContext context, Action<T> 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
);
}
}

0 comments on commit ba99109

Please sign in to comment.