Web​UI​Application Web​UI​Application Web​UI​Application Class

Definition

Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

Prerelease. Enables an app to receive notifications related to the lifetime of the app.

public : static class WebUIApplicationpublic static class WebUIApplicationPublic Static Class WebUIApplication
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The system creates this object when it runs the app.

Note

: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX)

.

Methods

EnablePrelaunch(Boolean) EnablePrelaunch(Boolean) EnablePrelaunch(Boolean)

Specifies whether pre-launching is enabled.

public : static void EnablePrelaunch(bool value)public static void EnablePrelaunch(Boolean value)Public Static Function EnablePrelaunch(value As Boolean) As void
Parameters
value
bool Boolean Boolean

true to enable pre-launching; otherwise, false.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

RequestRestartAsync(String) RequestRestartAsync(String) RequestRestartAsync(String)

Prerelease.

public : static IAsyncOperation<AppRestartFailureReason> RequestRestartAsync(PlatForm::String launchArguments)public static IAsyncOperation<AppRestartFailureReason> RequestRestartAsync(String launchArguments)Public Static Function RequestRestartAsync(launchArguments As String) As IAsyncOperation( Of AppRestartFailureReason )
Parameters
launchArguments
PlatForm::String String String
Returns
Attributes
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16225.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

RequestRestartForUserAsync(User, String) RequestRestartForUserAsync(User, String) RequestRestartForUserAsync(User, String)

Prerelease.

public : static IAsyncOperation<AppRestartFailureReason> RequestRestartForUserAsync(User user, PlatForm::String launchArguments)public static IAsyncOperation<AppRestartFailureReason> RequestRestartForUserAsync(User user, String launchArguments)Public Static Function RequestRestartForUserAsync(user As User, launchArguments As String) As IAsyncOperation( Of AppRestartFailureReason )
Parameters
user
User User User
launchArguments
PlatForm::String String String
Returns
Attributes
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16225.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Events

Activated Activated Activated

Occurs when the app is activated.

public : static event ActivatedEventHandler Activatedpublic static event ActivatedEventHandler ActivatedPublic Static Event Activated
Attributes

Remarks

Whenever your app is launched, the activated event is raised. This event can also be raised while your app is running if the system needs to pass the app parameters related to a new activation contract. You can use the activated event to restore the previous state of your app and to retrieve the activation parameters related to the contract for which your app is being activated. For a full list of the activation contracts and more details on their parameters see the ActivationKind enumeration. Note that you can also use the WinJS Onactivated event to handle app activation.

Note

: If your app needs to navigate the top level document for any reason you must first complete activation before attempting to do the top level navigation. If you attempt a top level navigation before activation completes your app will crash. This ensures that your app and the system are in a consistent state before the JavaScript context is torn down and recreated during the navigation.

See Also

EnteredBackground EnteredBackground EnteredBackground

Occurs when the app has begins running in the background (no UI is shown for the app).

public : static event EnteredBackgroundEventHandler EnteredBackgroundpublic static event EnteredBackgroundEventHandler EnteredBackgroundPublic Static Event EnteredBackground
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

LeavingBackground LeavingBackground LeavingBackground

Occurs when the app is about to leave the background and before the app's UI is shown.

public : static event LeavingBackgroundEventHandler LeavingBackgroundpublic static event LeavingBackgroundEventHandler LeavingBackgroundPublic Static Event LeavingBackground
Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Navigated Navigated Navigated

Occurs when the app is navigating.

public : static event NavigatedEventHandler Navigatedpublic static event NavigatedEventHandler NavigatedPublic Static Event Navigated
Attributes

Examples

Register for the navigated event and use the WebUINavigatedDeferral object to delay unfreezing your app’s UI until state is loaded asynchronously from a file.

function navigatedHandler(eventArgs) {

    var deferral = eventArgs.navigatedOperation.getDeferral();

    // Populate the text box with the previously saved value while the app visuals are frozen
    app.local.readText(myfile, "default").then(function (str) {
        document.getElementById("userText").value = str;

        // Complete the deferral to transition back to a live view of the app
        deferral.complete();
    }, function(error) {
        document.getElementById("userText").value = 'undefined';

        // Complete the deferral even in the case where readText fails 
        // else the app would appear hung to the user
        deferral.complete();
    });
}

Windows.UI.WebUI.WebUIApplication.addEventListener("navigated", navigatedHandler, false);

Remarks

In most cases an HTML based Windows Store app should never have to navigate or reload its top level document. To maintain global state and create a smooth user experience it is preferable that apps dynamically load and tear down their HTML as they need to within the same top level page.

However on some rare occasions your app may need to navigate or reload its top level document. When that happens the navigated event will be raised after the top level document is navigated or reloaded. It is raised after the DOMContentLoaded event and before the onLoad event. This event informs the new page that it is being loaded because of an in app navigation, not a new activation. You can use this event to restore any saved state for the page and re-initialize your app’s UI.

Note

Before this event is raised your app’s visuals will be frozen so that the user continues to see the previous page of your app. After navigated completes the system transitions to the UI of your new page. This allows your app to set up its UI on the new page before the user can see it. If you need to use asynchronous methods to initialize your UI you can use the navigatedOperation on the eventArgs to defer completion of the navigation.

Resuming Resuming Resuming

Occurs when the app is resuming.

public : static event ResumingEventHandler Resumingpublic static event ResumingEventHandler ResumingPublic Static Event Resuming
Attributes

Remarks

The system suspends your app whenever the user switches to another app or to the desktop. The system resumes your app whenever the user switches back to it. When the system resumes your app, the content of your variables and data structures is the same as it was before the system suspended the app. The system restores the app exactly where it left off, so that it appears to the user as if it's been running in the background. However, the app may have been suspended for a significant amount of time, so it should refresh any displayed content that might have changed while the app was suspended, such as news feeds or the user's location. If your app doesn't have any displayed content to refresh, there's no need for it to handle the resuming event.

See Also

Suspending Suspending Suspending

Occurs when the app is suspending.

public : static event SuspendingEventHandler Suspendingpublic static event SuspendingEventHandler SuspendingPublic Static Event Suspending
Attributes

Remarks

The system suspends your app whenever the user switches to another app or to the desktop. The system resumes your app whenever the user switches back to it. When the system resumes your app, the content of your variables and data structures is the same as it was before the system suspended the app. The system restores the app exactly where it left off, so that it appears to the user as if it's been running in the background.

The system attempts to keep your app and its data in memory while it's suspended. However, if the system does not have the resources to keep your app in memory, the system terminates your app. When the user switches back to a suspended app that has been terminated, the app receives an activated event and should check whether its session state objects are defined. If the objects are defined, the app should load that data.

The system doesn't notify an app when it's terminated, so your app must save its application data and release exclusive resources and file handles when it's suspended, and restore them when the app is activated after termination.

You should also release any exclusive resources, like file handles at suspend, so that they can be used by other apps while your app is suspended. Your app can also listen to the Oncheckpoint event to handle the app being suspended.

Note

If you need to do asynchronous work when your app is being suspended, you will need to defer completion of suspend until after your work completes. You can use the suspendingOperation.getDeferral method to delay completion of suspend until after you complete the deferral.

See Also

See Also