Model-View Question

Now that I have finally fixed a major issue in my app that I’ve been working on for quite some time, I have finally been able to stress test other areas, and something popped up that I think is related to sharing data between a view and a model. In my app I have a metronome class which is based around Vinns lovely sample-accurate metronome as discussed in http://www.rawmaterialsoftware.com/viewtopic.php?f=8&t=7221. The Metronome is fantastic. Really. I figured I should have the Metronome do its own thing, generate and play its pulse, and then notify my Transport class each beat. The Transport class (called TransportControl) just handles creating a record and play button, a bpm textbox, a running beat/bar counter etc. Play/start is trigger either by clicking the play button or by spacebar using the ApplicationCommandTarget.

My Metronome class has a ListenerList ( and I add(register) my TransportControl with it. I notify and pass each beat from my Metro to a callback in my Transport via the ListenerList’s signaling mechanism— myBeatListeners.call ( &TransportControl::myCallbackMethod, m_currentBeat );

This seems to work great most of the time, but sometimes crashes my program. I have tried locking the MessageManager before making the call but the problem persists. Ive identified this as the source of the issue, and commenting out the message eradicates the crashes but then I obviously no longer update the beat/bar counter in my Transport.

Does this look like the right approach or is there a more appropriate way I should be communicating beat/bar from my metro to my transport? Perhaps there should be a different lock I create when updating the beat/bar in my metronome, and then signal the transport class, but instead of passing the data into the callback, have the Transport lock briefly copy the value from the Metro to a local member. I figured passing by value into the callback like I am currently doing would be fine… Perhaps I am over complicating this! Thoughts?