static object obj = new object();
 static void log(string message)
        {
            lock (obj)
            {
                using (FileStream fsError = new FileStream("C:\\testlog.txt", FileMode.Append, FileAccess.Write, FileShare.Write))
                {
                    using (StreamWriter swError = new StreamWriter(fsError, Encoding.Default))
                    {
                        swError.WriteLine(message);
                    }
                }
                Monitor.PulseAll(obj);
                Monitor.Wait(obj);
            }
        }

相关文章:

  • 2021-06-20
  • 2021-10-08
  • 2021-10-15
  • 2022-03-08
  • 2021-08-30
  • 2022-12-23
  • 2021-07-20
  • 2021-04-17
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案