Multithreaded Graphics
We mentioned earlier that VCL isn't designed to be manipulated simultaneously by multiple threads, but this statement isn't entirely accurate. VCL has the capability to have multiple threads manipulate individual graphics objects. Thanks to new Lock() and Unlock() methods introduced in TCanvas, the entire Graphics unit has been made thread-safe. This includes the TCanvas, TPen, TBrush, TFont, TBitmap, TMetafile, TPicture, and TIcon classes.
The code for these Lock() methods is similar in that it uses a critical section and the EnterCriticalSection() API function (described earlier in this chapter) to guard access to the canvas or graphics object. After a particular thread calls a Lock() method, that thread is free to exclusively ...
Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.