Editare

Partajați prin


HttpContent.CopyToAsync Method

Definition

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

Overloads

CopyToAsync(Stream)

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

CopyToAsync(Stream, TransportContext)

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

CopyToAsync(Stream, CancellationToken)

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

CopyToAsync(Stream, TransportContext, CancellationToken)

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

Remarks

This operation does not block.

This method uses SerializeToStreamAsync(Stream, TransportContext, CancellationToken) if implemented or SerializeToStreamAsync(Stream, TransportContext) internally to serialize the content into the given stream. If the content has been previously buffered, for example, by calling LoadIntoBufferAsync(), the method will return the buffered content and not call the serialization method.

CopyToAsync(Stream)

Source:
HttpContent.cs
Source:
HttpContent.cs
Source:
HttpContent.cs

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

public:
 System::Threading::Tasks::Task ^ CopyToAsync(System::IO::Stream ^ stream);
public System.Threading.Tasks.Task CopyToAsync (System.IO.Stream stream);
member this.CopyToAsync : System.IO.Stream -> System.Threading.Tasks.Task
Public Function CopyToAsync (stream As Stream) As Task

Parameters

stream
Stream

The target stream.

Returns

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned Task object will complete after all of the content has been written to the stream object passed as the stream parameter.

Applies to

CopyToAsync(Stream, TransportContext)

Source:
HttpContent.cs
Source:
HttpContent.cs
Source:
HttpContent.cs

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

public:
 System::Threading::Tasks::Task ^ CopyToAsync(System::IO::Stream ^ stream, System::Net::TransportContext ^ context);
public System.Threading.Tasks.Task CopyToAsync (System.IO.Stream stream, System.Net.TransportContext context);
public System.Threading.Tasks.Task CopyToAsync (System.IO.Stream stream, System.Net.TransportContext? context);
member this.CopyToAsync : System.IO.Stream * System.Net.TransportContext -> System.Threading.Tasks.Task
Public Function CopyToAsync (stream As Stream, context As TransportContext) As Task

Parameters

stream
Stream

The target stream.

context
TransportContext

Information about the transport (channel binding token, for example). This parameter may be null.

Returns

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned Task object will complete after all of the content has been written to the stream object passed as the stream parameter.

Applies to

CopyToAsync(Stream, CancellationToken)

Source:
HttpContent.cs
Source:
HttpContent.cs
Source:
HttpContent.cs

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

public:
 System::Threading::Tasks::Task ^ CopyToAsync(System::IO::Stream ^ stream, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task CopyToAsync (System.IO.Stream stream, System.Threading.CancellationToken cancellationToken);
member this.CopyToAsync : System.IO.Stream * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function CopyToAsync (stream As Stream, cancellationToken As CancellationToken) As Task

Parameters

stream
Stream

The target stream.

cancellationToken
CancellationToken

The cancellation token to cancel the operation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task object will complete after all of the content has been written to the stream object passed as the stream parameter.

Applies to

CopyToAsync(Stream, TransportContext, CancellationToken)

Source:
HttpContent.cs
Source:
HttpContent.cs
Source:
HttpContent.cs

Serialize the HTTP content into a stream of bytes and copies it to the stream object provided as the stream parameter.

public:
 System::Threading::Tasks::Task ^ CopyToAsync(System::IO::Stream ^ stream, System::Net::TransportContext ^ context, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task CopyToAsync (System.IO.Stream stream, System.Net.TransportContext? context, System.Threading.CancellationToken cancellationToken);
member this.CopyToAsync : System.IO.Stream * System.Net.TransportContext * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Function CopyToAsync (stream As Stream, context As TransportContext, cancellationToken As CancellationToken) As Task

Parameters

stream
Stream

The target stream.

context
TransportContext

Information about the transport (channel binding token, for example). This parameter may be null.

cancellationToken
CancellationToken

The cancellation token to cancel the operation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This operation will not block. The returned Task object will complete after all of the content has been written to the stream object passed as the stream parameter.

Applies to