On a busy or slow system, the CScheduler unit test could fail because it assumed all threads would be done after a couple of milliseconds.
Replace the hard-coded sleep with a task that reschedules itself until the task queue is empty, and then shuts down the queue servicing threads.