# Delayed Message Processing?

**URL:** <https://forum.kirupa.com/t/delayed-message-processing/294016>\
**Category:** flash\
**Created:** [August 7, 2009, 12:20am UTC](https://forum.kirupa.com/t/delayed-message-processing/294016 "2009-08-07T00:20:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![drakoniis](https://avatars.discourse-cdn.com/v4/letter/d/7ba0ec/32.png) [@drakoniis](https://forum.kirupa.com/u/drakoniis)\
**Post date:** [August 7, 2009, 12:20am UTC](https://forum.kirupa.com/t/delayed-message-processing/294016/1 "2009-08-07T00:20:26Z")

</div>

I’ve been working with a 3rd-party multiplayer engine for a game I’m developing. A lot of messages get sent during certain times (loading, etc) to the point where it is possible that multiple messages may be sent per gameloop. To solve this problem, I am attempting to create a delayed message processing scheme. Essentially, this function is invoked every time a new message is received:

```auto

        // called by the Client
        public function PushMessage(gameMsg:GameMessage):void
        {
            messageQueue.push(gameMsg);
        }

```

And at a point in the gameloop, I want to process these messages and clear the message queue. The only problem: there is no assurance that the messageQueue won’t be modified during that time. The messages in AS3 are basically interrupts (possibly overlapping), and I can’t find any way to temporarily disable event dispatching for a specific EventDispatcher-derived class.

So at this point I can think of only two options. The first is to write a mutex using a Boolean and setTimeout. I do not want to do this for obvious reasons (bad! BAD!). The second is to give up on a delayed processing model.

Any ideas? Is there a nice way to tell an EventDispatcher to stop invoking listeners and simply queue messages?
