DedicatedWorkerGlobalScope Class

The global object of a dedicated worker (https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-dedicatedworkerglobalscope-interface): the messages it posts are fired at its Worker object, and the errors it does not handle are propagated to it.

public sealed class DedicatedWorkerGlobalScope : WorkerGlobalScope
Inheritance
WorkerGlobalScope DedicatedWorkerGlobalScope

Properties

NameDescription
OnMessageGets or sets the event handler of the message event.
OnMessageErrorGets or sets the event handler of the messageerror event.
WorkerNamehttps://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-name

Gets or sets the event handler of the message event.

public Action<Event>? OnMessage { get; set; }

OnMessageError

WorkerGlobalScope.cs

Gets or sets the event handler of the messageerror event.

public Action<Event>? OnMessageError { get; set; }

https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-name

public string WorkerName { get; }

Methods

NameDescription
CancelAnimationFrame(uint)https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animationframeprovider-cancelanimationframe
Close()Closes the worker: its event loop ends once the running task completes (https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-close).
PostMessage(object?, StructuredSerializeOptions?)Posts a message to the Worker object (https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage-options).
PostMessage(object?, IReadOnlyList<object>)Posts a message to the Worker object (https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage).
RequestAnimationFrame(FrameRequestCallback)https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-animationframeprovider-requestanimationframe: runs the callback at the next frame of the worker. There is no rendering: the frames run at a fixed rate (60 frames per second) measured with DomEventLoop.TimeProvider.

CancelAnimationFrame(uint)

WorkerGlobalScope.cs

https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#animationframeprovider-cancelanimationframe

public void CancelAnimationFrame(uint handle)

Closes the worker: its event loop ends once the running task completes (https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-close).

public void Close()

PostMessage overloads

PostMessage(object?, StructuredSerializeOptions?)

WorkerGlobalScope.cs

Posts a message to the Worker object (https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage-options).

public void PostMessage(object? message, StructuredSerializeOptions? options = null)

PostMessage(object?, IReadOnlyList<object>)

WorkerGlobalScope.cs

Posts a message to the Worker object (https://html.spec.whatwg.org/multipage/workers.html#dom-dedicatedworkerglobalscope-postmessage).

public void PostMessage(object? message, IReadOnlyList<object> transfer)

RequestAnimationFrame(FrameRequestCallback)

WorkerGlobalScope.cs

https://html.spec.whatwg.org/multipage/imagebitmap-and-animations.html#dom-animationframeprovider-requestanimationframe: runs the callback at the next frame of the worker. There is no rendering: the frames run at a fixed rate (60 frames per second) measured with DomEventLoop.TimeProvider.

public uint RequestAnimationFrame(FrameRequestCallback callback)

Parameters

callback FrameRequestCallback

Returns

uint

Exceptions

DomException
A NotSupportedError when the owner of the worker is not a window (a nested worker).

See also