Callback Routines

All callback routines run in a separate thread from the main program. So, all multithread issues are in full force. In particular, sharing data, drawing to windows, and doing I/O must be properly coordinated and controlled. The Visual Fortran Sample POKER.F90 (in the  ...\DF98\SAMPLES\QUICKWIN\POKER folder) is a good example of how to control access to shared resources.

QuickWin callback routines, both for menu callbacks and mouse callbacks, should do a minimum of processing and then return. While processing a callback, the program will appear to be non-responsive because messages are not being serviced. This is why it is important to return quickly.

If more processing time is needed in a callback, another thread should be started to perform this work; threads can be created by calling the Win32 API CreateThread. (For more information on creating and using threads, see Creating Multithread Applications.) If a callback routine does not start a new thread, the callback will not be reentered until it is done processing.