Supports asynchronous sharing operations by creating and returning a DataRequestDeferral object.
Syntax
var dataRequestDeferral = dataRequest.getDeferral();
Parameters
This method has no parameters.
Return value
Type: DataRequestDeferral
An object that allows you to share or send content asynchronously.
Remarks
The GetDeferral method allows your app to call a function during a share operation, so that your app can asynchronously generate the DataPackage object for the target app.
Use this method when you want to use an asynchronous function call to generate the DataPackage during a share operation. This function must return a DataPackage object within 200ms to prevent the operation from timing out. If your app shares content that takes more time to package, such as a collection of files or photos, don't use this method. Instead, use the SetDataProvider method to assign a delegate to a DataPackage and return that DataPackage to the target app.
Windows Phone 8
This API is not implemented and will throw an exception if called.
Examples
The following sample shows how to get a DataRequestDeferral object by using the GetDeferral method.
function registerForShare() { var dataTransferManager = Windows.ApplicationModel.DataTransfer.DataTransferManager.getForCurrentView(); dataTransferManager.addEventListener("datarequested", shareImageHandler); } function shareImageHandler(e) { var request = e.request; request.data.properties.title = "Share Image Example"; request.data.properties.description = "A demonstration that shows how to share an image."; var deferral = request.getDeferral(); Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("images\\smalllogo.png").then(function (thumbnailFile) { request.data.properties.thumbnail = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(thumbnailFile); return Windows.ApplicationModel.Package.current.installedLocation.getFileAsync("images\\logo.png"); }).done(function (imageFile) { request.data.setBitmap(Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile)); deferral.complete(); }, function (err) { request.failWithDisplayText(err); }); }
Requirements
|
Minimum supported client | Windows 8 |
|---|---|
|
Minimum supported server | Windows Server 2012 |
|
Minimum supported phone | Windows Phone 8 |
|
Namespace |
|
|
Metadata |
|
See also
Build date: 2/25/2013