Lock-KFProcess

Syntax

Lock-KFProcess
  [-Key] <key> 
  [-MaxWaitInSeconds <wait-time> (5)] 
  [-ThrowErrors[:$true]]

Support

>= kenaflow 2.0.3

Return

$null on failure.

A lock handle (-ne $null) on success.

Description

To synchronize multiple kenaflow workflows outside a SharePoint / List item context you can use this cmdlet to gather a lock with a custom key.

Please read this article for further details: Locking.

Parameters

[-Key] <key>

The key that is used by multiple workflows to gather the same (!) lock.

[-MaxWaitInSeconds <wait-time> (5)]

Specified (in seconds), how long the workflow waits for the lock if it already registered.

Default: 5 seconds.

[-ThrowErrors[:$true]]

This is a default parameter for all kenaflow cmdlets. If set to $true (default!) the engine will pass exception within the cmdlet to the script for further handling.

Example

$lock = Lock-KFProcess -Key "TestLockKey" -MaxWaitInSeconds 10
if( $lock -ne $null ) {
	Test-KFProcessLock -Handle $lock
	Unlock-KFProcess $lock
} else {
	Write-KFLog "Cannot get a handle for the given key."
}