Observable.IntervalまたはObservable.Timerを使用します。タイマーは、あなたがdueTimeで渡すことを許可します
e.q.
// Repeat every 2 seconds.
IObservable<long> observable = Observable.Interval(TimeSpan.FromSeconds(2));
// Token for cancelation
CancellationTokenSource source = new CancellationTokenSource();
// Create task to execute.
Action action = (() => Console.WriteLine("Action started at: {0}", DateTime.Now));
Action resumeAction = (() => Console.WriteLine("Second action started at {0}", DateTime.Now));
// Subscribe the obserable to the task on execution.
observable.Subscribe(x => { Task task = new Task(action); task.Start();
task.ContinueWith(c => resumeAction());
}, source.Token);
は 'Timer'と何が問題なのですか?必要に応じて、タイマーコールバックを使用して新しいタスクを開始することができます。 –
[System.Threading.Timerのタスクベースの置き換えはありますか?]の複製が可能ですか?(http://stackoverflow.com/questions/4890915/is-there-a-task-based-replacement-for-system-threading-タイマー) –