System.IO.StreamOperationsImplementation.FlushAsync_AbstractStream C# (CSharp) Méthode

FlushAsync_AbstractStream() static private méthode

static private FlushAsync_AbstractStream ( Stream stream ) : IAsyncOperation
stream Stream
Résultat IAsyncOperation
        internal static IAsyncOperation<Boolean> FlushAsync_AbstractStream(Stream stream)
        {
            Debug.Assert(stream != null);
            Debug.Assert(stream.CanWrite);
            Contract.EndContractBlock();

            Func<CancellationToken, Task<Boolean>> flushOperation = async (cancelToken) =>
            {
                if (cancelToken.IsCancellationRequested)  // CancellationToken is non-nullable
                    return false;

                await stream.FlushAsync(cancelToken).ConfigureAwait(continueOnCapturedContext: false);
                return true;
            };

            // Construct and run the async operation:
            return AsyncInfo.Run<Boolean>(flushOperation);
        }
        #endregion FlushAsync implementations

Usage Example

Exemple #1
0
        public IAsyncOperation <Boolean> FlushAsync()
        {
            Contract.Ensures(Contract.Result <IAsyncOperation <Boolean> >() != null);
            Contract.EndContractBlock();

            Stream str = EnsureNotDisposed();

            return(StreamOperationsImplementation.FlushAsync_AbstractStream(str));
        }
All Usage Examples Of System.IO.StreamOperationsImplementation::FlushAsync_AbstractStream