DeflateStream.CopyToAsync(Stream, Int32, CancellationToken) 方法


使用指定的缓冲区大小,从当前 Deflate 流中异步读取字节并将其写入到另一流中。Asynchronously reads the bytes from the current Deflate stream and writes them to another stream, using a specified buffer size.

 override System::Threading::Tasks::Task ^ CopyToAsync(System::IO::Stream ^ destination, int bufferSize, System::Threading::CancellationToken cancellationToken);
public override System.Threading.Tasks.Task CopyToAsync (System.IO.Stream destination, int bufferSize, System.Threading.CancellationToken cancellationToken);
override this.CopyToAsync : System.IO.Stream * int * System.Threading.CancellationToken -> System.Threading.Tasks.Task



向其中复制当前 Deflate 流的内容的流。The stream to which the contents of the current Deflate stream will be copied.


缓冲区的大小(以字节为单位)。The size, in bytes, of the buffer. 此值必须大于零。This value must be greater than zero. 默认大小为 81920。The default size is 81920.


要监视取消请求的标记。The token to monitor for cancellation requests. 默认值是 NoneThe default value is None.


表示异步复制操作的任务。A task that represents the asynchronous copy operation.


利用 CopyToAsync 方法,你可以在不阻塞主线程的情况下执行占用大量资源的 i/o 操作。The CopyToAsync method enables you to perform resource-intensive I/O operations without blocking the main thread. Windows 8.x 应用商店Windows 8.x Store 应用或 桌面desktop 应用中一个耗时的流操作可能阻塞 UI 线程并让您的应用看起来好像不工作时,这种性能的考虑就显得尤为重要了。This performance consideration is particularly important in a Windows 8.x 应用商店Windows 8.x Store app or 桌面desktop app where a time-consuming stream operation can block the UI thread and make your app appear as if it is not working. 异步方法与 Visual Basic 和C#中的 asyncawait 关键字结合使用。The async methods are used in conjunction with the async and await keywords in Visual Basic and C#.

如果在操作完成前取消该操作,则返回的任务将包含 Task.Status 属性的 TaskStatus.Canceled 值。If the operation is canceled before it completes, the returned task contains the TaskStatus.Canceled value for the Task.Status property.

复制从当前 Deflate 流中的当前位置开始。Copying begins at the current position in the current Deflate stream.