RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCanvas.TryLock Method

Locks the canvas if it is currently unlocked.

Pascal
function TryLock: Boolean;
C++
__fastcall Boolean TryLock();

Call TryLock to prevent other threads from writing on the surface of the canvas until the Unlock method is called. Unlike calls to the Lock method, which nest so that every call to Lock must be matched with a subsequent call to Unlock, TryLock need only be matched by a call to Unlock if the canvas was not already locked.  

If the canvas is unlocked, TryLock locks the canvas, sets the LockCount property to 1, and returns true. If the canvas is already locked, TryLock returns false without making any changes. 

Use TryLock before attempting changes to the canvas that could interfere with other code that is protected by a Lock/Unlock pair of method calls. 

 

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