Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataProviderDeferral class

Applies to Windows and Windows Phone

Used by a source app's deferral delegate to notify a DataPackage object that the source app will produce data from another asynchronous function.

Syntax


public ref class DataProviderDeferral sealed 

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Version(0x06020000)]

Members

The DataProviderDeferral class has these types of members:

Methods

The DataProviderDeferral class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
Complete Informs a DataPackage that it is ready for processing.

 

Remarks

Source apps have the option of promising data formats to target apps, instead of supplying the format immediately. A common example is when a source app supports an image format, such as JPG, but doesn't create the format unless the target app requests it. To learn more about how this type of exchange works with source and target apps, see How to support pull scenarios. You might also want to download our Sharing content source app sample.

Examples

The following code shows how to use a DataProviderDeferral object to defer a request from a target app.


async private void OnDeferredImageRequestedHandler(DataProviderRequest request)
{
    if (this.imageFile != null)
    {
        // A deferral object is required because this method uses "await" before setting the 
        // data in the DataPackage.
        var deferral = request.GetDeferral();

        var imageStream = await this.imageFile.OpenAsync(FileAccessMode.Read);

        // Decode the image.
        var imageDecoder = await BitmapDecoder.CreateAsync(imageStream);

        // Re-encode the image at 50% width and height.
        var inMemoryStream = new InMemoryRandomAccessStream();
        var imageEncoder = await BitmapEncoder.CreateForTranscodingAsync(inMemoryStream, imageDecoder);
        imageEncoder.BitmapTransform.ScaledWidth = (uint)(imageDecoder.OrientedPixelWidth * 0.5);
        imageEncoder.BitmapTransform.ScaledHeight = (uint)(imageDecoder.OrientedPixelHeight * 0.5);
        await imageEncoder.FlushAsync();

        request.SetData(RandomAccessStreamReference.CreateFromStream(inMemoryStream));

        await log(OutputText, "Image has been set via deferral");

        // The data is set. Signal that the operation is complete.
        deferral.Complete();
    }
    else
    {
        await log(OutputText, "Error: imageFile is null");
    }
}


Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

Metadata

Windows.winmd

 

 

Show:
© 2014 Microsoft