Observable.Interval 또는 Observable.Timer를 사용하십시오. 타이머를 통해 만기일을 통과 할 수 있습니다.
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- 타이머) –