$Cache.TryLock

Overview

Tries to acquire lock for a shared key.

string $Cache.TryLock(key: string)

Arguments

string key

Shared lock key.

Returns

Token value in string if lock has acquired, otherwise null.

Remarks

This method immediately checks to shared key is locked and generates token if shared key is not locked. Does not perform any wait operation for availability, if you want to wait for short period, please use the Lock method instead.

Example

var tokenValue = $Cache.TryLock('mylock'); if (tokenValue != null) { // Locked code block $Cache.ReleaseLock('mylock',tokenValue1); } else { // Already locked }

See Also

Copyright © 2010 - 2023 Emakin. All rights reserved.