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

CheckAsyncTaskInProgress() private method

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

            Task t = _asyncReadTask;

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