Table of Contents

Class WakeLockSentinel

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The WakeLockSentinel interface of the Screen Wake Lock API can be used to monitor the status of the platform screen wake lock, and manually release the lock when needed.

[Value("WakeLockSentinel")]
public class WakeLockSentinel : EventTarget
Inheritance
WakeLockSentinel
Inherited Members

Remarks

The screen wake lock prevents device screens from dimming or locking when an application needs to keep running.

A screen wake lock is requested using the 'WakeLock.Request' method, which returns a {{jsxref('Promise')}} that fulfills with a WakeLockSentinel object if the lock is granted.

An acquired screen wake lock can be released manually via the 'WakeLockSentinel.Release' method, or automatically via the platform screen wake lock. The latter may occur if the document becomes inactive or loses visibility, if the device is low on power, or if the user turns on a power save mode.
A released WakeLockSentinel cannot be re-used: a new sentinel must be requested using 'WakeLock.Request' if a new lock is needed.
Releasing all WakeLockSentinel instances of a given wake lock type will cause the underlying platform wake lock to be released.

An event is fired at the WakeLockSentinel if the platform lock is released, allowing applications to configure their UI, and re-request the lock if needed.

-Stay awake with the Screen Wake Lock API

See also on MDN

Constructors

WakeLockSentinel()

public WakeLockSentinel()

Properties

Onrelease

[Value("onrelease")]
public EventHandlerNonNull Onrelease { get; set; }

Property Value

EventHandlerNonNull

Released

The released read-only property of the WakeLockSentinel interface returns a boolean that indicates whether a WakeLockSentinel has been released.

[Value("released")]
public bool Released { get; }

Property Value

bool

A boolean value that is false until the WakeLockSentinel has been released (either through a call to Release() or because the lock has been released automatically) and the WakeLockSentinelrelease event has been emitted, after which it becomes true and no longer changes.

Remarks

The WakeLockSentinel is released when the associated platform screen wake lock is revoked; afterwards released will always return true.
If a subsequent screen wake lock is required, the application will need to request a new screen wake lock (the current WakeLockSentinel cannot be reused).

-Stay awake with the Screen Wake Lock API

See also on MDN

Type

The type read-only property of the WakeLockSentinel interface returns a string representation of the currently acquired WakeLockSentinel type.

[Value("type")]
public WakeLockType Type { get; }

Property Value

WakeLockType

A string representation of the currently acquired wake lock type.
Currently, the value is always screen, which represents a screen wake lock.
It prevents devices from dimming or locking the screen.

Remarks

Methods

Release()

The release() method of the WakeLockSentinel interface releases the WakeLockSentinel, returning a {{jsxref("Promise")}} that is resolved once the sentinel has been successfully released.

[Value("release")]
public Task<GlobalObject.Undefined> Release()

Returns

Task<GlobalObject.Undefined>

Returns a Promise that resolves with undefined.

Remarks