From 9bb545efcd181b5b47f332fd9c178eb3bff4c905 Mon Sep 17 00:00:00 2001 From: Daniel Weber Date: Wed, 16 May 2018 16:42:43 +0200 Subject: [PATCH] SynchronizationContextScheduler.Schedule: Avoid unnecessary allocation on one code path. --- .../SynchronizationContextScheduler.cs | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs b/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs index 5a3a04128b..0ec534f1a9 100644 --- a/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs @@ -57,22 +57,20 @@ public override IDisposable Schedule(TState state, Func { - _context.PostWithStartComplete(() => + if (!d.IsDisposed) { - if (!d.IsDisposed) - { - d.Disposable = action(this, state); - } - }); - } + d.Disposable = action(this, state); + } + }); return d; }