Is there a way to tell which Tasks are currently running in Task Parallel Library?

前端 未结 3 1205
小鲜肉
小鲜肉 2020-12-19 14:16

I can\'t see a way to see which tasks are running. There is the Task.Current property, but what if there are multiple tasks running? Is there a way to get this kind of infor

3条回答
  •  佛祖请我去吃肉
    2020-12-19 14:53

    You can create a TaskScheduler class deriving from the provided one. Within that class you have full control and can add logging either side of the execution. See for example: http://msdn.microsoft.com/en-us/library/ee789351.aspx

    You'll also need to use a Taskfactory with an instance of your class as the scheduler.

提交回复
热议问题