Thread Synchronization Issue?
This is my problem:
I've got a function listening to a particular event. When this function is invoked (the event has fired) it is supposed to do some work (a lot). However, this function is invoked a lot of times, as the event fires a lot. All events seem have their own threads, so several threads run the method concurrently. And this makes Explorer 5.0 hang.
So I'm wondering if there's some synchronization in explorer. I tried to solve it like this:
this should work: if an event is fired, the 'working' flag is set and all events fired will be ignored until the first event is done. In theory, that is.
this.AFunction = function()
return; //Or wait. I choose to ignore this event.
this.IsWorking = true;
//work your magic
this.IsWorking = false;
In real life, the flag isn't always set to true even though 'this.IsWorking' has been set to true. How is this? I don't know how explorer handles threads, but I could imaging that they've done something stupid like duplicating primitives for each thread instead of letting them share them. Anyway, does anyone know how to fix this? Oh, and I have no control over the events.
Thanks on advance,
Perhaps you need to either "return true" or "return false" when you don't want to handle the event yourself. If you "return true", that allows other handlers to finish. If you "return false", you cancel any other handlers.
Another thing you may not be aware of, is that IE "bubbles" the event. If you add
and you will see the bubbling process. Each object that fires the event will in turn fire the alert.
BTW, this debug process may put your browser into a dive, so be prepared to bail.
Thanks for responding.
However, the events I'm responding to is not part of the browser events, but rather part of the system I'm working with = custom events but their there to stay and there not produced by me, but my fellow developers. I'm stuck...
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)