DataProviderRequest.GetDeferral 方法

定义

返回 DataProviderDeferral 对象。

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

返回

数据提供程序延迟对象。

示例

async void OnDeferredImageRequestedHandler(DataProviderRequest request)
{
    // Provide updated bitmap data using delayed rendering.
    if (this.imageStream != null)
    {
        DataProviderDeferral deferral = request.GetDeferral();
        InMemoryRandomAccessStream inMemoryStream = new InMemoryRandomAccessStream();

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

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

        request.SetData(RandomAccessStreamReference.CreateFromStream(inMemoryStream));
        deferral.Complete();
    }
}

注解

若要了解详细信息,检查如何异步生成请求的数据

适用于