The wxMTCall library

From RoutineWiki

Jump to: navigation, search


Credits and License details


The source code available in this page is copyright of the following author(s):


The software provided in this page is maintained by:


No warranty of any kind is implied for the uses of the source code provided in this page. It is provided 'as is'. Use at your own risk. See license for details.


This software is licensed under BSD License.

Other licenses

Please contact with the maintainer(s) for other license(s).

About the library

This library provides a safe-way to call from secondary threads some functions that currently are only available for main thread. The motivation for doing this library that we are pleased to provide to you, comes from the limitation of wxExecute in wxWidgets 2.8.9. The workaround for this function is included in the library. Please send comments and feedback to *Mel Viso.


follow this link for downloading the library


Implementation classes list:

  • wxMTHandler: static initialization container. This class ensures correct event handling for secondary thread calls.
  • wxMTCallBase : base class for multithread calls. This class specifies the requirementes for derivatives using pure declarations.
  • template <typename retType> class wxMTCall : Template class required for specifying the return type of the mt-populated methods.

Example classes list:

  • wxMTExecute : implementation of wxExecute for secondary threads.
  • wxMTLogXXX : implementation of the wxLogXXX (where XXX=Trace,Verbose,Message, Warning, Status or Error) calls for secondary threads.

Details of implementation

The library uses the following secuence for the incoming call :

  • 1 (calling thread) Is the call from the main thread? If so, do the calll and return the value. End.
  • 2 (calling thread) Save the arguments in a custom message, then post the message and wait in a semaphore.
  • 3 (main thread) Read the parameters, do the call, store the result, and post wakeup for the semaphore.
  • 5 (calling thread) Recover the result and return.


This is a little class that implements a event handling for intercepting requests coming from secondary threads. This class ensures dynamic (jit) initialization and liberation of resources at exit.


This class includes synchronization objects for pseudo-synchronous call from secondary threads and pure virtual functions for interface requiriments of derived classes.

wxMTCall template

These template classes are specializations required for specifying the return type of the function populated for use from secondary threads.

Personal tools