Monday, February 23, 2009

Command Pattern - Queuing Commands

This is a slight variation of the previous example, with a much different result. If you look at the source you'll see that only the click handlers of the buttons have changed.

Now, whenever you click a green, red, or blue button each action will queue up waiting for you to click the black button. Once you click the black button, every action queued up (meaning each circle waiting to be created) will execute all at the same time.

View Queued Commands example