ResourceHandler.HandleResourceAsync

ResourceHandler.HandleResourceAsync method

This method is responsible for handling the resource asynchronously when the document is saved with a SaveAsync method. In it you can save the Resource to the stream or embed it into the parent resource, and then complete the work asynchronously, for example write the saved content to a remote storage.

public virtual Task HandleResourceAsync(Resource resource, ResourceHandlingContext context, 
    CancellationToken cancellationToken)
ParameterTypeDescription
resourceResourceThe Resource which will be handled.
contextResourceHandlingContextResource handling context.
cancellationTokenCancellationTokenThe cancellation token.

Return Value

A task that represents the asynchronous part of the handling.

Exceptions

exceptioncondition
OperationCanceledExceptionOperation was cancelled.

Remarks

Save or Embed must be called before the method returns (before its first await), because the reference to the resource is written to the parent resource as soon as the method returns. The returned task is awaited when the document has been serialized. The default implementation calls HandleResource.

See Also