我有Observable.Interval(TimeSpan.FromSeconds(1))
和一个用户每隔一段时间检查一次数据库中的内容。但有时候,当我从DB执行检查时,我想立即执行另一次检查(再次调用该用户,因为我知道队列中有东西)。无效 - 将可观察间隔与手动触发器组合在一起
我已经成功地实现由订户方法内部间隔与while
结合类似的事情:
Observable
.Interval(TimeSpan.FromSeconds(1))
.Sample(TimeSpan.FromSeconds(1)) //to avoid multiple 'stacked' intervals
.Subscribe(RepeatAction);
private void RepeatAction(long _)
{
bool wasSuccess;
do
{
wasSuccess = CheckingInDB(); //Long operation
} while (wasSuccess);
}
但有可能实现这种行为与纯反应?
什么是SubscribeInContext方法?那从哪里来的? – Enigmativity