System.IO.NetFxToWinRtStreamAdapter.WriteAsync C# (CSharp) Méthode

WriteAsync() public méthode

public WriteAsync ( Windows.Storage.Streams.IBuffer buffer ) : UInt32>.IAsyncOperationWithProgress
buffer Windows.Storage.Streams.IBuffer
Résultat UInt32>.IAsyncOperationWithProgress
        public IAsyncOperationWithProgress<UInt32, UInt32> WriteAsync(IBuffer buffer)
        {
            if (buffer == null)
            {
                // Mapped to E_POINTER.
                throw new ArgumentNullException(nameof(buffer));
            }

            if (buffer.Capacity < buffer.Length)
            {
                ArgumentException ex = new ArgumentException(SR.Argument_BufferLengthExceedsCapacity);
                ex.SetErrorCode(HResults.E_INVALIDARG);
                throw ex;
            }

            // Commented due to a reported CCRewrite bug. Should uncomment when fixed:
            //Contract.Ensures(Contract.Result<IAsyncOperationWithProgress<UInt32, UInt32>>() != null);
            //Contract.EndContractBlock();

            Stream str = EnsureNotDisposed();
            return StreamOperationsImplementation.WriteAsync_AbstractStream(str, buffer);
        }