Correctly obtain the number of active tasks.