CancellationTokenSource cancellationTokenSource = new CancellationTokenSource();
Task tasks = PeriodicTaskFactory.Start(() => LongRunningOperation(), intervalInMilliseconds: 1000, synchronous: false, cancelToken: cancellationTokenSource.Token);
int taskId = Task.WaitAny(tasks);
and my LongRunningOperation
private String LongRunningOperation()
{
...
return proj.Name;
}
but the problem is how to get value from LongRunningOperation
method back in Task
. Method tasks.Results
not exists. And I want to get back the value from each Task.
I get PeriodicTaskFactory class from here
Is there a Task based replacement for System.Threading.Timer?
Thank you