Vcl.Graphics.TCustomCanvas.Lock

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

procedure Lock;

C++

void __fastcall Lock();

Properties

Type Visibility Source Unit Parent
procedure
function
public
Vcl.Graphics.pas
Vcl.Graphics.hpp
Vcl.Graphics TCustomCanvas

Description

Prevents other threads from drawing on the canvas.

Use Lock in a multithreaded application to prevent other threads from drawing on the canvas. Lock prevents other cooperating threads in the application from executing until the Unlock method is called. Nested calls to Lock increment the LockCount property so that the canvas is not unlocked until the last lock is released.

In multithreaded applications that use Lock to protect a canvas, all calls that use the canvas must be protected by a call to Lock. Any thread that does not lock the canvas before using it introduces potential bugs.

Because Lock prevents other threads from executing, it can adversely affect performance. Do not call Lock unless there is a possibility that another thread interferes with drawing on the canvas.

See Also