LockManager Class

The locks of the storage key of a window or of a worker (https://w3c.github.io/web-locks/#api-lock-manager, Navigator.Locks): named resources that the windows and the workers of an origin acquire to coordinate their work. The locks are shared by the browsing contexts of a browsing context group and by their workers.

public sealed class LockManager

Methods

NameDescription
Query()Returns the held locks and the pending requests of the lock manager (https://w3c.github.io/web-locks/#dom-lockmanager-query), of all the windows and workers that share it. As request(), it waits for the activation of a prerendering document.
Request(string, LockGrantedCallback)Requests an exclusive lock: see LockManager.Request.
Request(string, LockOptions, LockGrantedCallback)Requests the lock of a resource (https://w3c.github.io/web-locks/#dom-lockmanager-request-name-options-callback): callback is called from a task of the event loop once the lock is granted, and the lock is held until the task it returns completes. The returned task is completed with the result of the callback once the lock is released; it fails with the abort reason when the signal of the options aborts the request, with an AbortError when the lock is stolen, and with a DomException when the request is invalid. The request of a prerendering document is made when the document is activated.

Returns the held locks and the pending requests of the lock manager (https://w3c.github.io/web-locks/#dom-lockmanager-query), of all the windows and workers that share it. As request(), it waits for the activation of a prerendering document.

public Task<LockManagerSnapshot> Query()

Request overloads

Request(string, LockGrantedCallback)

LockManager.cs

Requests an exclusive lock: see LockManager.Request.

public Task<object?> Request(string name, LockGrantedCallback callback)

Request(string, LockOptions, LockGrantedCallback)

LockManager.cs

Requests the lock of a resource (https://w3c.github.io/web-locks/#dom-lockmanager-request-name-options-callback): callback is called from a task of the event loop once the lock is granted, and the lock is held until the task it returns completes. The returned task is completed with the result of the callback once the lock is released; it fails with the abort reason when the signal of the options aborts the request, with an AbortError when the lock is stolen, and with a DomException when the request is invalid. The request of a prerendering document is made when the document is activated.

public Task<object?> Request(string name, LockOptions options, LockGrantedCallback callback)
Parameters
name string
The name of the resource, which does not start with -.
options LockOptions
The options.
callback LockGrantedCallback
The callback, called with the lock (or null when it is not available, with the LockOptions.IfAvailable option).
Returns

Task<object?>

See also