On 15 Sep 2008 at 15:44, Ck wrote: > > If your main thread is a MFC thread, then you'll need to pump the FOX > > message dispatch system manually from within the MFC message loop. > > > How to do this? > Can you give an example?
Look at the source for TnFXApp::run() and FXApp::run(). Basically it runs via getNextEvent() and dispatchEvent(). > I think I need to use FXObject... > > struct Data; > class Receiver: public FXObject > { > public: > ... > /** For sync calls. */ > void syncCall(Data *data); > > /** For async calls. */ > long tryHandle (FXObject *sender, FXSelector sel, void *ptr); > } > > For sync call from worker thread I can do: > m_receiver->syncCall(m_data); > > For async: > m_receiver->getEventLoop()->postAsyncMessage(bla bla); > > How to pump Receiver message system from MFC message lopp? See above. If you wish to invoke some synchronous call which isn't threadsafe, you should set up a message handler which receives async messages from other threads and executes the required call. I personally would have it pass a BoundFunctor such that any thread can invoke any function in any other thread arbitrarily. I have an implementation of this actually in Tn but not TnFOX - it wouldn't be hard to port over though. I might add that to the todo list actually. > PS Is this ok, what I write to you personally instead of to maillist? I'd prefer the mailing list so others can search it in the future. HTH, Niall ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Tnfox-discussion mailing list Tnfox-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tnfox-discussion