views:

31

answers:

1

Hi,

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 executed 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!

+1  A: 

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.

Jon Skeet
Definitely consider chaining tasks with ContinueWith - it should simplify your life immensely.
Andrew Anderson