I can see the MFC timer coming from a diff thread. But the dlg msg pump is the same as the ANVIL main GUI thread. Debug the ::GetCurrentThreadID() on the OnOK() call. See if it is the same. Im my codebase is the same thread.
Using the code you provided, the dialog thread should be the same as the parent, even though it's non-modal. Create does not create a new thread. Don't get the MFC Create confused with the API call. Now the timer callback could be coming from another thread... I'm not 100% sure in this case.
Is there a bridge between OpenQuant or any of the retail strategy development platforms and the Anvil API?
I seen many post about having a timer on ANVIL. Here is a simple way of having a timer in Anvil without having to worry about multi-threading. You need to add an observable to <I>B_GetAdminObservable()</I>. On the <i>Process()</i> handle monitor the M_HEARTBEAT message. Check some timer object for interval and perform your operationat the specified time. Here is some sample code. <i> void CObserver:rocess(const Message* message, Observable* from, const Message* additionalInfo) { static CTimer _Timer(60000); switch(message->GetType()) { case M_HEARTBEAT: { // Timer Check if ( _Timer.TimeToRun() ) { // Do your thing here } } break; } } </i> The Timer class here: <i> class CTimer { public: CTimer(DWORD dIntervalMs, DWORD dLastTriggeredMs = 0) { m_IntervalMs = dIntervalMs; m_LastTriggeredMs = dLastTriggeredMs; } bool TimeToRun() { if ( :GetTickCount() - m_LastTriggeredMs) > m_IntervalMs ) { m_LastTriggeredMs = ::GetTickCount(); m_bDidItRun = true; return true; } return false; } private: DWORD m_IntervalMs; DWORD m_LastTriggeredMs; }; </i>
FYI I learned that OpenQuant uses QuickFIX to connect to a trading technologies FIX adapter and others have been able to use that as an example to make their own FIX implementation. So, I believe it's doable but will require some elbow grease on my part.
One thing I learned with using the M_HEARTBEAT message is that if you are running a black box over the internet then this message usually arrives but there are times when a heartbeat message is missed. I had to add special coding into my app to account for times when this message was missed. Does anyone know what the purpose of the IdleObserver is?
Okay, thanks! I saw that it was being used in the Trader example and included it into my app. It was sending lots of messages and I think that is why my app kept choking. Now I have finally got my threaded app working and I removed this observer and it is working much better. It still doesn't process as many symbols as I would like but I'm also running the black box over the internet which is not a good setup. Hopefully once I get a machine setup at Assent I'll be able to process much more. Thanks to all of you for your help with this! I couldn't have done it without you!! When I get a free moment I will remove all of the logic from my program and post it so that others have a threaded example to look at.