| Version: 3.2.5

Static Public Member Functions | List of all members
wxPowerResource Class Reference
Class List by Category » Miscellaneous

`#include <wx/power.h>`

## Detailed Description

Helper functions for acquiring and releasing the given power resource.

If an application performs a long running task without user interaction it is often necessary to prevent the system from automatically suspending or powering off the screen and Acquire() method can be used to do this.

Notice that currently this functionality is only implemented for MSW and macOS.

If possible, use wxPowerResourceBlocker class to ensure that Release() is called instead of calling it manually.

Since
  3.1.0

  ##

Library: wxBase
Category: Miscellaneous

See also
  wxPowerResourceBlocker

## Static Public Member Functions

static bool | Acquire (wxPowerResourceKind kind, const wxString &reason=wxString())
| Acquire a power resource for the application. More...
static void | Release (wxPowerResourceKind kind)
| Release a previously acquired power resource. More...

## Member Function Documentation

## ◆ Acquire()

static bool wxPowerResource::Acquire | ( | wxPowerResourceKind | kind,
|  | const wxString & | reason = `wxString()`
| ) |  |

static

Acquire a power resource for the application.

If successful, the system will not automatically power of the screen or suspend until Release() is called.

Every call to Acquire must be matched by a corresponding call to Release() or the system will not suspend until the application ends, use wxPowerResourceBlocker to ensure that this happens.

Parameters

  kind | Power resource required, either wxPOWER_RESOURCE_SCREEN or wxPOWER_RESOURCE_SYSTEM.
  reason | Optional reason may be specified which might be used on some platforms to inform the user what is preventing power saving. It should usually describe the operation requiring the resource and specifying it is strongly recommended.

Returns
  Returns true if the acquisition was successful.

See also
  Release()

## ◆ Release()

static void wxPowerResource::Release | ( | wxPowerResourceKind | kind | ) |

static

Release a previously acquired power resource.

Release must be called for every Acquire() call made to restore normal power saving behaviour

Parameters

  kind | Power resource to be released.

See also
  Acquire()