Share via

DataProviderDeferral Class


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

public ref class DataProviderDeferral sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class DataProviderDeferral final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class DataProviderDeferral
Public NotInheritable Class DataProviderDeferral
Object Platform::Object IInspectable DataProviderDeferral

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)


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();


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

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


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. You might want to download our Sharing content source app sample.



Informs a DataPackage that it is ready for processing.

Applies to