BackgroundExecutionManager.RequestAccessAsync Method

Definition

Overloads

RequestAccessAsync()

Requests that the app be permitted to run background tasks.

RequestAccessAsync(String)

Asynchronously requests that the app be permitted to run background tasks.

RequestAccessAsync()

Requests that the app be permitted to run background tasks.

public:
 static IAsyncOperation<BackgroundAccessStatus> ^ RequestAccessAsync();
/// [Windows.Foundation.Metadata.Overload("RequestAccessAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<BackgroundAccessStatus> RequestAccessAsync();
[Windows.Foundation.Metadata.Overload("RequestAccessAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<BackgroundAccessStatus> RequestAccessAsync();
function requestAccessAsync()
Public Shared Function RequestAccessAsync () As IAsyncOperation(Of BackgroundAccessStatus)

Returns

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

Attributes

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 this method to request background access.

Tip

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

See also

Applies to

RequestAccessAsync(String)

Asynchronously requests that the app be permitted to run background tasks.

public:
 static IAsyncOperation<BackgroundAccessStatus> ^ RequestAccessAsync(Platform::String ^ applicationId);
/// [Windows.Foundation.Metadata.Overload("RequestAccessForApplicationAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
 static IAsyncOperation<BackgroundAccessStatus> RequestAccessAsync(winrt::hstring const& applicationId);
[Windows.Foundation.Metadata.Overload("RequestAccessForApplicationAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public static IAsyncOperation<BackgroundAccessStatus> RequestAccessAsync(string applicationId);
function requestAccessAsync(applicationId)
Public Shared Function RequestAccessAsync (applicationId As String) As IAsyncOperation(Of BackgroundAccessStatus)

Parameters

applicationId
String

Platform::String

winrt::hstring

The package-relative application identifier (PRAID) of the app to be permitted to run background tasks. The specified app must be in the same package as the calling app. For more info on the PRAID, see the Id attribute of the Application element.

If you are hosting background task(s) in an out-of-process COM server, separate from your main application, then pass as the argument for applicationId the PRAID of the application that defines the windows.backgroundTask extension in its own package manifest.

Returns

An asynchronous request operation. On successful completion, contains a member of the BackgroundAccessStatus enumeration that specifies the outcome.

Attributes

Remarks

Version Behavior
Windows 8/Windows 8.1 Prompts 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.1 Does not prompt the user, but must be called before registering any background tasks.
Windows 10 Does 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 this method, or RequestAccessAsync, to request background access.

Tip

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

See also

Applies to