www.webdeveloper.com
Results 1 to 3 of 3

Thread: Thread Synchronization Issue?

  1. #1
    Join Date
    Dec 2002
    Posts
    11

    Unhappy 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:

    Code:
    this.AFunction = function()
    {
       if(this.IsWorking)
       {
          return; //Or wait. I choose to ignore this event.
       }
    
       this.IsWorking = true;
       //work your magic
       this.IsWorking = false;
    }
    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.

    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,
    Nille

  2. #2
    Join Date
    Nov 2002
    Posts
    4,473
    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

    alert(event.srcElement.tagName);

    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.

  3. #3
    Join Date
    Dec 2002
    Posts
    11
    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...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles