TextReader.ReadToEndAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
ReadToEndAsync() |
Reads all characters from the current position to the end of the text reader asynchronously and returns them as one string. |
ReadToEndAsync(CancellationToken) |
Reads all characters from the current position to the end of the text reader asynchronously and returns them as one string. |
ReadToEndAsync()
- Source:
- TextReader.cs
- Source:
- TextReader.cs
- Source:
- TextReader.cs
Reads all characters from the current position to the end of the text reader asynchronously and returns them as one string.
public:
virtual System::Threading::Tasks::Task<System::String ^> ^ ReadToEndAsync();
public virtual System.Threading.Tasks.Task<string> ReadToEndAsync ();
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task<string> ReadToEndAsync ();
abstract member ReadToEndAsync : unit -> System.Threading.Tasks.Task<string>
override this.ReadToEndAsync : unit -> System.Threading.Tasks.Task<string>
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member ReadToEndAsync : unit -> System.Threading.Tasks.Task<string>
override this.ReadToEndAsync : unit -> System.Threading.Tasks.Task<string>
Public Overridable Function ReadToEndAsync () As Task(Of String)
Returns
A task that represents the asynchronous read operation. The value of the TResult
parameter contains a string with the characters from the current position to the end of the text reader.
- Attributes
Exceptions
The number of characters is larger than Int32.MaxValue.
The text reader has been disposed.
The reader is currently in use by a previous read operation.
Remarks
The TextReader class is an abstract class. Therefore, you do not instantiate it in your code. For an example of using the ReadToEndAsync method, see the StreamReader.ReadToEndAsync method.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ReadToEnd().
See also
- ReadToEndAsync()
- ReadToEndAsync()
- File and Stream I/O
- How to: Read Text from a File
- How to: Write Text to a File
Applies to
ReadToEndAsync(CancellationToken)
- Source:
- TextReader.cs
- Source:
- TextReader.cs
- Source:
- TextReader.cs
Reads all characters from the current position to the end of the text reader asynchronously and returns them as one string.
public:
virtual System::Threading::Tasks::Task<System::String ^> ^ ReadToEndAsync(System::Threading::CancellationToken cancellationToken);
public virtual System.Threading.Tasks.Task<string> ReadToEndAsync (System.Threading.CancellationToken cancellationToken);
abstract member ReadToEndAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<string>
override this.ReadToEndAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<string>
Public Overridable Function ReadToEndAsync (cancellationToken As CancellationToken) As Task(Of String)
Parameters
- cancellationToken
- CancellationToken
The token to monitor for cancellation requests.
Returns
A task that represents the asynchronous read operation. The value of the TResult
parameter contains a string with the characters from the current position to the end of the text reader.
Exceptions
The number of characters is larger than Int32.MaxValue.
The text reader has been disposed.
The reader is currently in use by a previous read operation.
The cancellation token was canceled. This exception is stored into the returned task.
Remarks
The TextReader class is an abstract class. Therefore, you do not instantiate it in your code. For an example of using the ReadToEndAsync(CancellationToken) method, see the ReadToEndAsync(CancellationToken) method.
This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ReadToEnd().