【发布时间】:2015-12-07 00:50:55
【问题描述】:
我有基于队列运行的任务列表,但我需要检查任务是否完成。根据每个任务返回的状态,我必须执行该功能。
Task.Factory.StartNew(
() =>
{
string fileName;
while (!filePaths.IsCompleted)
{
if (!filePaths.TryTake(out fileName)) continue;
this.ReadFileContents(fileName, VMCallBack);
}
}, _cts.Token);
【问题讨论】:
-
是否需要等到任务执行完毕?
标签: c# multithreading task-parallel-library