TestScheduler稳定版本1.0.1621的示例 [英] TestScheduler examples for stable version 1.0.1621

查看:91
本文介绍了TestScheduler稳定版本1.0.1621的示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我是否可以在Rx .net的稳定版本中使用TestScheduler获取一些示例?  我可以看到许多使用看起来像旧界面的例子,并且稳定版本似乎没有任何内容。我感兴趣的是
即将多次运行调度程序到特定时间点,我可以看到有一个RunTo方法,现在似乎已经删除了。有替代品吗?  我可以从TestScheduler创建一个observable并在调度程序
上调用Start,它提供了正确的结果,但是如果我再次调用我什么也得不到,是否需要进行一些调用以重置调度程序并重新运行它?  任何信息或示例都将受到赞赏。

Is there any where I can get some examples using the TestScheduler in the stable version of Rx .net?  I can see a lot of examples using what looks like the old interface and there seems to be nothing around the stable version. I am interested in being about to run a scheduler to a particular point in time multiple times and i can see that there was a RunTo method which now seems to have removed. Is there a replacement?   I can create an observable from a TestScheduler and call Start on the scheduler which provided the correct results however if I make another call I get nothing, is there some call that needs to be make to reset the scheduler and rerun it?  Any info or examples would be appreciated.

 

谢谢,

 

 

推荐答案

I也很想知道测试调度程序是否有任何示例。我一直在研究编程反应扩展和编程的例子。 Linq的书由Jesse Liberty&保罗贝茨,但Testscheduler的东西让我有点难过
,如:

I too, would love to know if there are any examples for the Test Scheduler. I have been working through the examples form Programming Reactive Extensions & Linq book by Jesse Liberty & Paul Betts but the Testscheduler stuff has me a little stumped such as:


var sched = new TestScheduler();
var input = sched.CreateColdObservable(
sched.OnNextAt(205, 1),
sched.OnNextAt(305, 10),
sched.OnNextAt(405, 100),
sched.OnNextAt(505, 1000),
sched.OnNextAt(605, 10000),
sched.OnCompletedAt<int>(1100.0));
int i = 0;

var windows = input.Window(
// We're going to start a window every 100 milliseconds..
Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(100), sched).Take(7),
// ..and then close it 50ms later.
x => Observable.Timer(TimeSpan.FromMilliseconds(50), sched));

windows.Timestamp(sched).Subscribe(obs => {
int current = ++i;
Console.WriteLine("Started Observable {0} at {1}ms", current, obs.Timestamp.Millisecond);
// Subscribe to the inner Observable and print its items
obs.Value.Subscribe(
item => Console.WriteLine(" {0} at {1}ms", item, sched.Now.Millisecond),
() => Console.WriteLine("Ended Observable {0} at {1}ms\n",
current, sched.Now.Millisecond));
});


这篇关于TestScheduler稳定版本1.0.1621的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆