Reactive Extensions将操作置于onComplete或使用Concat?

时间:2017-01-01 20:41:40

标签: c# reactive-programming

如果P.DoWork()依赖于d1.DoWork()和d2.DoWork()的完成:

    p.Dependencies.ToObservable()
                  .SelectMany(
                    x=>Observable.Return(x)
                                 .SubscribeOn(NewThreadScheduler.Default)
                                 .Select(a => a.Dowork())
                    )
                 .Subscript(_={},()=p.DoWork())

将p.DoWork()放入onComplete:

  var po =Observable.Return(p)
            .SubscribeOn(NewThreadScheduler.Default)
                    .Select(a => a.Dowork());
  var ds = p.Dependencies.ToObservable()
              .SelectMany(
                x=>Observable.Return(x)
                             .SubscribeOn(NewThreadScheduler.Default)
                             .Select(a => a.Dowork())
                );
  ds.Concat(po).subscribe();

或使用Concat:

AudioGraph

同样的?

0 个答案:

没有答案