TextWriter.WriteAsync TextWriter.WriteAsync TextWriter.WriteAsync TextWriter.WriteAsync Method

Definition

Writes data to the text stream asynchronously.

Overloads

WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32)

Writes a subarray of characters to the text stream asynchronously.

WriteAsync(StringBuilder, CancellationToken) WriteAsync(StringBuilder, CancellationToken)

Asynchronously writes a string builder to the text stream.

WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken)

Asynchronously writes a character memory region to the text stream.

WriteAsync(String) WriteAsync(String) WriteAsync(String) WriteAsync(String)

Writes a string to the text stream asynchronously.

WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[])

Writes a character array to the text stream asynchronously.

WriteAsync(Char) WriteAsync(Char) WriteAsync(Char) WriteAsync(Char)

Writes a character to the text stream asynchronously.

WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32) WriteAsync(Char[], Int32, Int32)

Writes a subarray of characters to the text stream asynchronously.

public:
 virtual System::Threading::Tasks::Task ^ WriteAsync(cli::array <char> ^ buffer, int index, int count);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task WriteAsync (char[] buffer, int index, int count);
abstract member WriteAsync : char[] * int * int -> System.Threading.Tasks.Task
override this.WriteAsync : char[] * int * int -> System.Threading.Tasks.Task
Public Overridable Function WriteAsync (buffer As Char(), index As Integer, count As Integer) As Task

Parameters

buffer
Char[]

The character array to write data from.

index
Int32 Int32 Int32 Int32

The character position in the buffer at which to start retrieving data.

count
Int32 Int32 Int32 Int32

The number of characters to write.

Returns

A task that represents the asynchronous write operation.

Exceptions

The index plus count is greater than the buffer length.

The text writer is currently in use by a previous write operation.

Remarks

The TextWriter class is an abstract class. Therefore, you do not instantiate it in your code. For an example of using the WriteAsync method, see the StreamWriter.WriteAsync method.

See also

WriteAsync(StringBuilder, CancellationToken) WriteAsync(StringBuilder, CancellationToken)

Asynchronously writes a string builder to the text stream.

public virtual System.Threading.Tasks.Task WriteAsync (System.Text.StringBuilder value, System.Threading.CancellationToken cancellationToken = null);
abstract member WriteAsync : System.Text.StringBuilder * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.WriteAsync : System.Text.StringBuilder * System.Threading.CancellationToken -> System.Threading.Tasks.Task

Parameters

value
StringBuilder StringBuilder StringBuilder StringBuilder

The string, as a string builder, to write to the text stream.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A task that represents the asynchronous write operation.

Remarks

This method is equivalent to calling WriteAsync(stringBuilder.ToString()), however, it uses the StringBuilder.GetChunks() method to avoid creating the intermediate string.

WriteAsync(ReadOnlyMemory<Char>, CancellationToken) WriteAsync(ReadOnlyMemory<Char>, CancellationToken)

Asynchronously writes a character memory region to the text stream.

public virtual System.Threading.Tasks.Task WriteAsync (ReadOnlyMemory<char> buffer, System.Threading.CancellationToken cancellationToken = null);
abstract member WriteAsync : ReadOnlyMemory<char> * System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.WriteAsync : ReadOnlyMemory<char> * System.Threading.CancellationToken -> System.Threading.Tasks.Task

Parameters

buffer
ReadOnlyMemory<Char>

The character memory region to write to the text stream.

cancellationToken
CancellationToken CancellationToken CancellationToken CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

A task that represents the asynchronous write operation.

WriteAsync(String) WriteAsync(String) WriteAsync(String) WriteAsync(String)

Writes a string to the text stream asynchronously.

public:
 virtual System::Threading::Tasks::Task ^ WriteAsync(System::String ^ value);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task WriteAsync (string value);
abstract member WriteAsync : string -> System.Threading.Tasks.Task
override this.WriteAsync : string -> System.Threading.Tasks.Task
Public Overridable Function WriteAsync (value As String) As Task

Parameters

value
String String String String

The string to write. If value is null, nothing is written to the text stream.

Returns

A task that represents the asynchronous write operation.

Exceptions

The text writer is currently in use by a previous write operation.

Remarks

The TextWriter class is an abstract class. Therefore, you do not instantiate it in your code. For an example of using the WriteAsync method, see the StreamWriter.WriteAsync method.

See also

WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[]) WriteAsync(Char[])

Writes a character array to the text stream asynchronously.

public:
 System::Threading::Tasks::Task ^ WriteAsync(cli::array <char> ^ buffer);
[System.Runtime.InteropServices.ComVisible(false)]
public System.Threading.Tasks.Task WriteAsync (char[] buffer);
member this.WriteAsync : char[] -> System.Threading.Tasks.Task
Public Function WriteAsync (buffer As Char()) As Task

Parameters

buffer
Char[]

The character array to write to the text stream. If buffer is null, nothing is written.

Returns

A task that represents the asynchronous write operation.

Exceptions

The text writer is currently in use by a previous write operation.

See also

WriteAsync(Char) WriteAsync(Char) WriteAsync(Char) WriteAsync(Char)

Writes a character to the text stream asynchronously.

public:
 virtual System::Threading::Tasks::Task ^ WriteAsync(char value);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual System.Threading.Tasks.Task WriteAsync (char value);
abstract member WriteAsync : char -> System.Threading.Tasks.Task
override this.WriteAsync : char -> System.Threading.Tasks.Task
Public Overridable Function WriteAsync (value As Char) As Task

Parameters

value
Char Char Char Char

The character to write to the text stream.

Returns

A task that represents the asynchronous write operation.

Exceptions

The text writer is currently in use by a previous write operation.

Remarks

The TextWriter class is an abstract class. Therefore, you do not instantiate it in your code. For an example of using the WriteAsync method, see the StreamWriter.WriteAsync method.

See also

Applies to