Skip to content

Commit

Permalink
SynchronizationContextScheduler.Schedule: Avoid unnecessary allocatio…
Browse files Browse the repository at this point in the history
…n on one code path.
  • Loading branch information
danielcweber committed May 17, 2018
1 parent 25a2ab2 commit 9bb545e
Showing 1 changed file with 9 additions and 11 deletions.
Expand Up @@ -57,22 +57,20 @@ public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TSta
if (action == null)
throw new ArgumentNullException(nameof(action));

var d = new SingleAssignmentDisposable();

if (!_alwaysPost && _context == SynchronizationContext.Current)
{
d.Disposable = action(this, state);
return action(this, state);
}
else

var d = new SingleAssignmentDisposable();

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

return d;
}
Expand Down

0 comments on commit 9bb545e

Please sign in to comment.