Skip to main content
BackgroundExecutionManager.RequestAccessAsync(String) | requestAccessAsync(String) method

Requests that the app be permitted to run background tasks.

Syntax


Windows.ApplicationModel.Background.BackgroundExecutionManager.requestAccessAsync(applicationId).done( /* Your success and error handlers */ );

public static IAsyncOperation<BackgroundAccessStatus> RequestAccessAsync(
  string applicationId
)

Public Shared Function RequestAccessAsync(
  applicationId As String 
) As IAsyncOperation(Of BackgroundAccessStatus)

public:
static IAsyncOperation<BackgroundAccessStatus>^ RequestAccessAsync(
  String^ applicationId
)

Parameters

applicationId

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The Package Relative Application ID (PRAID) of the app to be permitted to run background tasks. The specified app must be in the same package as the calling app.

Return value

Type: IAsyncOperation<BackgroundAccessStatus>

When the operation completes, it returns a member of the BackgroundAccessStatus enumeration that specifies the outcome.

Remarks

VersionBehavior
Windows 8/Windows 8.1Prompts the user with a dialog box that requests that an app be added to the lock screen. Must be called before registering any background tasks.
Windows Phone 8.1Does not prompt the user, but must be called before registering any background tasks.
Windows 10Does not prompt the user, but must be called before registering any background tasks. You do not need to add the app to the lock screen in order to use background tasks in Windows 10, but you still need to call RequestAccessAsync to request background access.

 

Tip  Starting with Windows 10, it is no longer necessary to call this method from the UI thread.
 

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.ApplicationModel.Background
Windows::ApplicationModel::Background [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.Background
Windows::ApplicationModel::Background [C++]

Metadata

Windows.winmd

See also

BackgroundExecutionManager
RequestAccessAsync