System.IO.StreamWriter.CheckAsyncTaskInProgress C# (CSharp) Method

CheckAsyncTaskInProgress() private method

private CheckAsyncTaskInProgress ( ) : void
return void
        private void CheckAsyncTaskInProgress()
        {
            // We are not locking the access to _asyncWriteTask because this is not meant to guarantee thread safety. 
            // We are simply trying to deter calling any Write APIs while an async Write from the same thread is in progress.

            Task t = _asyncWriteTask;

            if (t != null && !t.IsCompleted)
                throw new InvalidOperationException(SR.InvalidOperation_AsyncIOInProgress);
        }