I'm using a non-threadsafe event API. wait()
is called, and from that call, event handlers are dispatched. I want to be able to, within an event handler, "sleep" for some time. Currently, I have a scheduler that schedules functions to be called at a later time, and have a bit of a hack that lets me use Scheduler.Sleeper(some_ienumerator) as the event handler, so I can yield timespans as a sort of sleep. Is there any better solution? If C# had Ruby-style Fibers, I would be able to make the scheduler have a Sleep() function that I can call, and the sleep stuff could be in a function called by the event handler, rather than the handler directly. Given the lack of easily-usable Fibers, is there anything else I can do?
EDIT FOR CLARIFICATION: I call wait(n)
where n is an amount of time, and during that wait call, the API calls the event handlers. The reason I want to "sleep" in some of those handlers is because this is for a game, where after clicking on something, an object might, for instance, glow for a second.