Thread safety in Visual Prolog

Thread safe:


 * Access facts

Not thread safe:


 * GUI
 * Streams
 * odbcConnection/odbcStatement

Facts
See Threadsafe facts.

GUI
Windows GUI is not thread safe, only the thread that runs the message pump of a window should accees that window. In Visual Prolog all windows (except modal dialogs) belong to the thread that have executed the vpi::init call.

Synchronization back to the GUI thread can be done using window::postAction, because the posted action will be executed by the GUI thread.

Modal dialogs run their own message pump and they are therefore owned by the thread that displays them.

Streams
Streams are in general not thread safe, but specific streams can be.

From Visual Prolog 7.4 the thread on messageControls are thread safe. In a GUI application stdio will thus be thread safe while it is redirected to a messageControl/messageForm, but if it is redirected to some other stream it will "inherit" the thread safety from that stream.

ODBC
An odbcConnection/odbcStatement is not thread safe, but different odbcConnection's/odbcStatement's can be accessed in parallel.