【发布时间】:2014-08-14 10:00:32
【问题描述】:
我有一个长期运行的任务(从 Kinect One 的深度图像创建纹理),它是使用 Reactive Extensions 实现的。其要点如下:
kinectWrapper.DepthFrames
.ObserveOn(new EventLoopScheduler())
.Select(f => do some CPU intensive data manipulation to create the color texture I want)
.Subscribe(colorFrame => fill texture on GPU)
问题是 select 和 subscribe 在系统上都相当繁重,不会全速运行。我已经设法让它在我的开发 PC 上以可接受的速度运行 .Sample(TimeSpan.FromMilliseconds(100)),但我宁愿让它根据 CPU 使用率降低帧速率。
我认为有两种可能:
- 创建一个辅助 IObservable 作为 Sample 的输入,动态限制主事件循环。
- 编写我自己的 IScheduler,当它被任务淹没时,它会丢弃计划任务。
【问题讨论】:
标签: system.reactive