On a second thought, i think the toublemaker is not my code :) It seems that reinstalling event loop works incorrectly, because it should make sure that previous event loop process is terminated. And hence any delays which was scheduled in it will be unscheduled by #ifCurtailed: block Delay>>wait "Schedule this Delay, then wait on its semaphore. The current process will be suspended for the amount of time specified when this Delay was created." self schedule. [delaySemaphore wait] ifCurtailed:[self unschedule]. The solution, is to promote fetcherProcess ivar to class var, to make sure that there is only one event loop process existing in system (but we could have multiple instance of InputEventFetcher singletons ;) 2009/4/21 Igor Stasenko <siguctua@gmail.com>:
I unsure if it because of my intrusions.. but it happens second time when i hit 'save the image'.
I can't give a textual trace, because at the moment when error appears, image is no longer able to receive the events.
Image are saved OK, but then it going through warm startup and throws this error. Now i know what is wrong, and the troublemaker is my code. :)
The Delay instance of EventPollingFetcher are created just once, and then reused in event loop. At the time when image saved, its already scheduled in Delay, but then new eventpolling fetcher get installed in new process, and same delay got rescheduled , which leads to this error.
Btw, i just found that saved image, has same problems - it throws the same error just a bit later after startup :)
One solution is to create a new delay each time we need to wait: (Delay forMilliseconds: EventPollDelay) wait.
another, is to make sure that given delay is not scheduled, by sending  #unschedule to it at the time when it reinitializing event fetcher.
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.