I run about 50 tasks (Task). Tasks are performed at different speeds.
I need to display the number of running tasks in WPF control .
As I understand it, there should be a counter that ++ at the start of the task, and -- at the completion of the task. As soon as the counter becomes == 0 , you need to call a specific method.
In theory, such a scenario should have a ready-made solution, but did not find anything suitable. The only thing that comes to mind is to make the counter int count = 0; and object countLock = new Object(); and change the value of count from different tasks like this lock(countLock) count++; . But it seems to me that there is a better solution?
Note: tasks are not started all at once, but by queues. A few started, a pause, a few more started, a pause. At this time, some of the tasks may be completed, and a few more run.