This documentation is archived and is not being maintained.

TextReader.Synchronized Method

Creates a thread-safe wrapper around the specified TextReader.

[Visual Basic]
Public Shared Function Synchronized( _
   ByVal reader As TextReader _
) As TextReader
public static TextReader Synchronized(
 TextReader reader
public: static TextReader* Synchronized(
 TextReader* reader
public static function Synchronized(
   reader : TextReader
) : TextReader;


The TextReader to synchronize.

Return Value

A thread-safe TextReader.


Exception Type Condition
ArgumentNullException reader is a null reference (Nothing in Visual Basic).


The current method returns a class that wraps around the specified TextReader instance and restricts access to it by multiple threads. All reads from the returned wrapper will be thread safe.

The following table lists examples of other typical or related I/O tasks.

To do this... See the example in this topic...
Create a text file. Writing Text to a File
Write to a text file. Writing Text to a File
Read from a text file. Reading Text from a File


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

TextReader Class | TextReader Members | System.IO Namespace | Working with I/O | Reading Text from a File | Writing Text to a File