浏览代码

Merge pull request #1177 from hez2010/master

Fix infinite recursive generics in CatchScheduler
Claire Novotny 5 年之前
父节点
当前提交
f867e71bf0
共有 1 个文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Rx.NET/Source/src/System.Reactive/Concurrency/CatchScheduler.cs

+ 2 - 1
Rx.NET/Source/src/System.Reactive/Concurrency/CatchScheduler.cs

@@ -108,7 +108,8 @@ namespace System.Reactive.Concurrency
                     _catchScheduler = scheduler;
                     _action = action;
 
-                    Disposable.SetSingle(ref _cancel, scheduler._scheduler.SchedulePeriodic((@this: this, state), period, tuple => tuple.@this?.Tick(tuple.state) ?? default));
+                    // Note that avoiding closure allocation here would introduce infinite generic recursion over the TState argument
+                    Disposable.SetSingle(ref _cancel, scheduler._scheduler.SchedulePeriodic(state, period, state1 => this.Tick(state1).state ?? default));
                 }
 
                 public void Dispose()