Delen via


DataRequest.GetDeferral Method

Definition

Supports asynchronous sharing operations by creating and returning a DataRequestDeferral object.

public:
 virtual DataRequestDeferral ^ GetDeferral() = GetDeferral;
DataRequestDeferral GetDeferral();
public DataRequestDeferral GetDeferral();
function getDeferral()
Public Function GetDeferral () As DataRequestDeferral

Returns

An object that allows you to share or send content asynchronously.

Examples

The following sample shows how to get a DataRequestDeferral object by using the GetDeferral method.

void DataRequested(DataTransferManager sender, DataRequestedEventArgs e)
{
    DataRequestDeferral deferral = e.Request.GetDeferral();
    e.Request.Data.Properties.Title = "Hello World!";
    e.Request.Data.Properties.Description = "This example shows how to share files and images.";
    if (this.dataPackageThumbnail != null)
    {
        e.Request.Data.Properties.Thumbnail = this.dataPackageThumbnail;
    }
    e.Request.Data.SetBitmap(imageStreamRef);
    deferral.Complete();
}

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.

Applies to