瀏覽代碼

Merge pull request #1116 from jkotas/generic-recursion

Avoid infinite generics recursion in SynchronizationContextScheduler
Oren Novotny 5 年之前
父節點
當前提交
03aa3ed315
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      Rx.NET/Source/src/System.Reactive/Concurrency/SynchronizationContextScheduler.cs

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

@@ -93,7 +93,8 @@ namespace System.Reactive.Concurrency
                 return Schedule(state, action);
             }
 
-            return DefaultScheduler.Instance.Schedule((scheduler: this, action, state), dt, (_, tuple) => tuple.scheduler.Schedule(tuple.state, tuple.action));
+            // Note that avoiding closure allocation here would introduce infinite generic recursion over the TState argument
+            return DefaultScheduler.Instance.Schedule(state, dt, (_, state1) => Schedule(state1, action));
         }
     }
 }