好的,在多线程系统中有两种方法可以将文本写入文件
哪一个比另一个好
第一种情况:有一个静态对象来锁定streamwriter并进行操作
第二种情况:
TextWriter twWaitingToBeFetched;
twWaitingToBeFetched = TextWriter.Synchronized(new StreamWriter(stringPath, true));
twWaitingToBeFetched.WriteLine(srNewComposedUrl);
twWaitingToBeFetched.Flush();
现在您认为哪个更好,为什么?
我需要多个线程任务来编写相同的流
C# .net 4.5 - WPF 应用程序