CachedFileUpdaterUI.FileUpdateRequested CachedFileUpdaterUI.FileUpdateRequested CachedFileUpdaterUI.FileUpdateRequested CachedFileUpdaterUI.FileUpdateRequested CachedFileUpdaterUI.FileUpdateRequested Event

Definition

Fires when the Windows requests a file update. This event fires once for each requested update.

public : event TypedEventHandler<CachedFileUpdaterUI, FileUpdateRequestedEventArgs> FileUpdateRequested
// Register
event_token FileUpdateRequested(TypedEventHandler<CachedFileUpdaterUI, FileUpdateRequestedEventArgs> const& handler) const;

// Revoke with event_token
void FileUpdateRequested(event_token const& cookie) const;

// Revoke with event_revoker
FileUpdateRequested_revoker FileUpdateRequested(auto_revoke_t, TypedEventHandler<CachedFileUpdaterUI, FileUpdateRequestedEventArgs> const& handler) const;
public event TypedEventHandler<CachedFileUpdaterUI, FileUpdateRequestedEventArgs> FileUpdateRequested
Public Event FileUpdateRequested As TypedEventHandler (Of CachedFileUpdaterUI, FileUpdateRequestedEventArgs)
function onFileUpdateRequested(eventArgs){/* Your code */}


cachedFileUpdaterUI.addEventListener("fileupdaterequested", onFileUpdateRequested);
cachedFileUpdaterUI.removeEventListener("fileupdaterequested", onFileUpdateRequested);

Examples

The File picker contracts sample demonstrates how to respond to a FileUpdateRequested event.


// Event handler
void CachedFileUpdaterUI_FileUpdateRequested(CachedFileUpdaterUI sender, FileUpdateRequestedEventArgs args)
{
    fileUpdateRequest = args.Request;
    fileUpdateRequestDeferral = fileUpdateRequest.GetDeferral();
    switch (cachedFileUpdaterUI.UIStatus)
    {
        case UIStatus.Hidden:
            fileUpdateRequest.Status = FileUpdateStatus.UserInputNeeded;
            fileUpdateRequestDeferral.Complete();
            break;
        case UIStatus.Visible:
            break;
        case UIStatus.Unavailable:
            fileUpdateRequest.Status = FileUpdateStatus.Failed;
            fileUpdateRequestDeferral.Complete();
            break;
    }
}

// Register for the event
cachedFileUpdaterUI.FileUpdateRequested += CachedFileUpdaterUI_FileUpdateRequested;

// Event handler
function onFileUpdateRequest(e) {
    fileUpdateRequest = e.request;
    fileUpdateRequestDeferral = fileUpdateRequest.getDeferral();

    switch (cachedFileUpdaterUI.uiStatus) {
        case Windows.Storage.Provider.UIStatus.hidden:
            fileUpdateRequest.status = Windows.Storage.Provider.FileUpdateStatus.userInputNeeded;
            fileUpdateRequestDeferral.complete();
            break;
        case Windows.Storage.Provider.UIStatus.visible:
            var url = scenarios[0].url;
            WinJS.Navigation.navigate(url, cachedFileUpdaterUI);
            break;
        case Windows.Storage.Provider.UIStatus.unavailable:
            fileUpdateRequest.status = Windows.Storage.Provider.FileUpdateStatus.failed;
            fileUpdateRequestDeferral.complete();
            break;
    }
}

// Register for the event
cachedFileUpdaterUI.addEventListener("fileupdaterequested", onFileUpdateRequest);

Both args and e (in C# and JS respectively) contain a FileUpdateRequestedEventArgs object.

Remarks

If your app participates in the Cached File Updater contract, you must register for this event in your app's activated event handler where you check for ActivationKind.CachedFileUpdater. You must respond to this FileUpdateRequested event by updating the file and setting the FileUpdateRequest.Status of the request. Use the CachedFileUpdaterUI.@Windows.Storage.Provider.CachedFileUpdaterUI.UpdateTarget?text=UpdateTarget property to determine whether your app should update the version file in its repository or the locally cached copy of the file in response to the request.

You can access information about the requested update by using the FileUpdateRequestedEventArgs.Request property on the object that is passed to your FileUpdateRequested event handler. 

If you need user input to complete the update, set the FileUpdateRequest.Status to FileUpdateStatus.UserInputNeeded and complete the request. If user interaction is available, another FileUpdateRequested will fire and your app can obtain user input and complete the request.