 
     # Give other (Node) events a chance to process
     @running = true
-    process.nextTick =>
+    setImmediate =>
       @running = false
       unless @active
         @emit("done")


    # Someone (us) just started paying attention, start processing events
    if @listeners.length == 1
      process.nextTick =>
        if @active
          @active._eventQueue.resume()
          @run()


ms  = require("ms")
Q   = require("q")
global.setImmediate ||= process.nextTick


# The browser event loop.
