RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TGraphicsObject.Lock Method

Blocks other execution threads from using the associated canvas until the Unlock method is called.

Pascal
procedure Lock;
C++
__fastcall Lock();

Call Lock in a multithreaded application before using the graphics object in a section of code that would not otherwise be thread-safe. Lock prevents other cooperating threads in the application from using the associated canvas until the Unlock method is called. Calls to Lock can be nested so that the canvas is not unlocked until the last lock is released. 

Because Lock prevents other threads from executing, it can adversely affect performance. Do not call Lock unless there is a danger that another thread might interfere with the drawing.

Note: Lock will do nothing unless the drawing surface sets the OwnerCriticalSection property. TCanvas objects automatically set the OwnerCriticalSection property when they use graphics objects.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!