Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ public override IDisposable Schedule<TState>(TState state, Func<IScheduler, TSta
if (action == null)
throw new ArgumentNullException(nameof(action));

if (_control.IsDisposed)
{
return Disposable.Empty;
}

var d = new SingleAssignmentDisposable();

_control.BeginInvoke(new Action(() =>
{
if (!d.IsDisposed)
if (!_control.IsDisposed && !d.IsDisposed)
d.Disposable = action(this, state);
}));

Expand Down Expand Up @@ -94,7 +99,10 @@ public override IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Fun
{
try
{
d.Disposable = action(scheduler1, state1);
if (!_control.IsDisposed && !d.IsDisposed)
{
d.Disposable = action(scheduler1, state1);
}
}
finally
{
Expand Down Expand Up @@ -156,7 +164,10 @@ public IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<

timer.Tick += (s, e) =>
{
state1 = action(state1);
if (!_control.IsDisposed)
{
state1 = action(state1);
}
};

timer.Interval = (int)period.TotalMilliseconds;
Expand Down