There seems some confusion around what it should achieve (when I wrote that code). There should be two sides of time manipulation:
"virtual expected time" that AdvanceBy() increases.
"virtual actual time" that some other method increases.
AdvanceBy() is called by MidiPlayer (or something else) whenever next set of MIDI events were processed. This method therefore should "block" until another thread manipulates the "virtual actual time" that is controlled by e.g. unit tests.
Considering the use cases where virtual actual time counter fails to run, there should be some safe-guard canceller within the virtual time manager that resumes the wait handle and throws exception.
There seems some confusion around what it should achieve (when I wrote that code). There should be two sides of time manipulation:
AdvanceBy() is called by MidiPlayer (or something else) whenever next set of MIDI events were processed. This method therefore should "block" until another thread manipulates the "virtual actual time" that is controlled by e.g. unit tests.
Considering the use cases where virtual actual time counter fails to run, there should be some safe-guard canceller within the virtual time manager that resumes the wait handle and throws exception.