开发者

.Net 4.0 parallel - how to know when task is finished

开发者 https://www.devze.com 2023-01-04 16:52 出处:网络
I have a Tasks table. Tasks are added to this table all the time. After task is finished, I should delete it from the table and perform some other operations. The tasks should be ex开发者_开发问答ecut

I have a Tasks table. Tasks are added to this table all the time. After task is finished, I should delete it from the table and perform some other operations. The tasks should be ex开发者_开发问答ecuted concurrently. If I use Task class (Task.Factory.StartNew...), how can I know when Task is finished, in order to perform some operations regarding to it?

Thanks in advance!


Well, you can test for completion with Task.IsCompleted. You can wait for a task to be completed with Task.Wait (or a variant). You can tell a task to do something else afterwards with Task.ContinueWith. The last one here may well be what you want here.

0

精彩评论

暂无评论...
验证码 换一张
取 消