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()
です。
ただし、コードを実行すると、最後に「完了」しか表示されません。数字も、「完了」も、「完了」だけです。
ここで何が間違っていますか?