TextWriter.Synchronized(TextWriter) 方法

定义

在指定的 TextWriter 周围创建线程安全包装。Creates a thread-safe wrapper around the specified TextWriter.

public:
 static System::IO::TextWriter ^ Synchronized(System::IO::TextWriter ^ writer);
public static System.IO.TextWriter Synchronized (System.IO.TextWriter writer);
static member Synchronized : System.IO.TextWriter -> System.IO.TextWriter
Public Shared Function Synchronized (writer As TextWriter) As TextWriter

参数

writer
TextWriter

要同步的 TextWriterThe TextWriter to synchronize.

返回

线程安全包装。A thread-safe wrapper.

异常

writernullwriter is null.

注解

对返回的包装的所有写入操作都是线程安全的。All write operations to the returned wrapper will be thread safe. 调用此方法可以确保一次只有一个线程可以在返回的TextWriter实例上执行方法。You call this method to ensure that only one thread at a time can execute the methods on the TextWriter instance that is returned. 有关同步和线程处理的详细信息,请参阅为多线程处理同步数据For more information about synchronization and threading, see Synchronizing Data for Multithreading.

有关常见 i/o 任务的列表, 请参阅常见 I/o 任务For a list of common I/O tasks, see Common I/O Tasks.

适用于

另请参阅