Lock Component Methods and Properties

Use the Lock component to make sure that a section of code does not run multiple times simultaneously.

For example, you can use this component when an automation is triggered by a user clicking a button. If the user double clicks the button, two automations might run at the same time, performing the same steps. To prevent this from happening, use the Lock component. Place the Lock component in a Global container. Make sure that it is a global component.

Here is an example automation that demonstrates the correct way to use the Lock component to prevent an automation from running simultaneously.

Here is an example automation that demonstrates queuing requests so that they run sequentially.



The Lock component has the following methods:





Requests a lock to prevent a section of code from running.

Use the timeout parameter to specify the number of seconds that the control waits for a lock before failing. If the RequestLock is successful, you must release it on the same thread when execution finishes. If the lock is not released on the same thread, the lock is not released until you restart the solution.

To prevent a perpetual lock, the best practice is to do all the necessary work in another automation and wrap that automation with a Try..Catch. This approach makes sure that the lock is always released.



Releases a lock that prevented code from running.

After you call the ReleaseLock method, the system process the next request. If there are no pending requests, the next execution trigger can request a lock.


Use these Lock component properties while processing the request to determine if other requests are pending:




Returns a True or False based whether there are requests for a lock pending.


Returns the number of requests.


Returns a True or False based on the current condition of the lock.


Related information

For more information, see Lock Component.


Privacy | Trademarks | Terms of Use | Feedback

Updated: 18 June 2020

© 2016 - 2020 Pegasystems Inc.  Cambridge, MA All rights reserved.


OpenSpan data classification label