Beispiel #1
0
        /// <summary>
        /// Asynchronously clears all buffers for this stream and causes any buffered data to be written
        /// to the underlying device.
        /// </summary>
        /// <remarks>
        /// Flushes the <see cref="BaseStream"/>.
        /// </remarks>
        /// <returns>A task that represents the asynchronous flush operation.</returns>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <exception cref="System.ObjectDisposedException">
        /// The stream has been disposed.
        /// </exception>
        /// <exception cref="System.NotSupportedException">
        /// The stream does not support writing.
        /// </exception>
        /// <exception cref="System.OperationCanceledException">
        /// The operation was canceled via the cancellation token.
        /// </exception>
        /// <exception cref="System.IO.IOException">
        /// An I/O error occurred.
        /// </exception>
        public override Task FlushAsync(CancellationToken cancellationToken)
        {
            CheckDisposed();
            CheckCanWrite();

            return(BaseStream.FlushAsync(cancellationToken));
        }
Beispiel #2
0
        public async Task WriteFooterAsync(CancellationToken cancellationToken = default)
        {
            if (!HasWrittenFooter)
            {
                await WriteFooterAsync(Schema, cancellationToken);

                HasWrittenFooter = true;
            }

            await BaseStream.FlushAsync(cancellationToken);
        }
Beispiel #3
0
 /// <summary>
 /// Flushes the stream asynchronously
 /// </summary>
 /// <param name="token">The <see cref="CancellationToken"/> for this task</param>
 public override async Task FlushAsync(CancellationToken token)
 {
     if (!IsConnected)
     {
         throw new InvalidOperationException("The FtpSocketStream object is not connected.");
     }
     if (BaseStream == null)
     {
         throw new InvalidOperationException("The base stream of the FtpSocketStream object is null.");
     }
     await BaseStream.FlushAsync(token);
 }
Beispiel #4
0
        /// <summary>
        /// Writes an object to the pipe.
        /// </summary>
        /// <param name="buffer">Object to write to the pipe</param>
        /// <param name="cancellationToken"></param>
        public async Task WriteAsync(byte[] buffer, CancellationToken cancellationToken = default)
        {
            try
            {
                await SemaphoreSlim.WaitAsync(cancellationToken);

                await WriteLengthAsync(buffer.Length, cancellationToken).ConfigureAwait(false);

                await BaseStream.WriteAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);

                await BaseStream.FlushAsync(cancellationToken).ConfigureAwait(false);
            }
            finally
            {
                SemaphoreSlim.Release();
            }
        }
Beispiel #5
0
 public override Task FlushAsync(CancellationToken cancellationToken) => BaseStream.FlushAsync(cancellationToken);
Beispiel #6
0
 /// <summary>
 /// Asynchronously clears all buffers for this stream and causes any buffered data
 /// to be written to the underlying device.
 /// </summary>
 /// <param name="cancellationToken">
 /// The token to monitor for cancellation requests. The default value is
 /// System.Threading.CancellationToken.None.
 /// </param>
 /// <returns>
 /// A task that represents the asynchronous flush operation.
 /// </returns>
 public override Task FlushAsync(CancellationToken cancellationToken)
 {
     return(BaseStream.FlushAsync(cancellationToken));
 }
        protected override Task FlushImplAsync(CancellationToken cancellationToken = default)
        {
            ThrowIfError();

            return(BaseStream.FlushAsync(cancellationToken));
        }