diff --git a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/ControlScheduler.cs b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/ControlScheduler.cs index 80d8510e80..0e4830d870 100644 --- a/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/ControlScheduler.cs +++ b/Rx.NET/Source/src/System.Reactive/Platforms/Desktop/Concurrency/ControlScheduler.cs @@ -52,11 +52,16 @@ public override IDisposable Schedule(TState state, Func { - if (!d.IsDisposed) + if (!_control.IsDisposed && !d.IsDisposed) d.Disposable = action(this, state); })); @@ -94,7 +99,10 @@ public override IDisposable Schedule(TState state, TimeSpan dueTime, Fun { try { - d.Disposable = action(scheduler1, state1); + if (!_control.IsDisposed && !d.IsDisposed) + { + d.Disposable = action(scheduler1, state1); + } } finally { @@ -156,7 +164,10 @@ public IDisposable SchedulePeriodic(TState state, TimeSpan period, Func< timer.Tick += (s, e) => { - state1 = action(state1); + if (!_control.IsDisposed) + { + state1 = action(state1); + } }; timer.Interval = (int)period.TotalMilliseconds;