Vcl.Graphics.TGraphicsObject.Lock
Delphi
procedure Lock;
C++
void __fastcall Lock();
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
protected | Vcl.Graphics.pas Vcl.Graphics.hpp |
Vcl.Graphics | TGraphicsObject |
Description
Blocks other execution threads from using the associated canvas until the Unlock method is called.
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.