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
要同步的 TextWriter。The TextWriter to synchronize.
返回
线程安全包装。A thread-safe wrapper.
例外
writer 为 null。writer 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.