【发布时间】:2013-08-24 06:10:51
【问题描述】:
我正在阅读IntroToRx,但示例代码有点问题。这是我的代码的总和:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace LearningReactiveExtensions
{
public class Program
{
static void Main(string[] args)
{
var observable = Observable.Interval(TimeSpan.FromSeconds(5));
observable.Subscribe(
Console.WriteLine,
() => Console.WriteLine("Completed")
);
Console.WriteLine("Done");
Console.ReadKey();
}
}
}
如果我对这本书的理解正确,这应该会向控制台写入一个数字序列,每五秒一次永远,因为我从来没有Dispose()这个序列。
但是,当我运行代码时,我得到的只是最后的“完成”。没有数字,没有“完成”,只有“完成”。
我在这里做错了什么?
【问题讨论】:
标签: system.reactive reactive-programming