public static void Start() { ThreadStart start = new ThreadStart(ThreadAction); Thread th = new Thread(start); th.IsBackground = true; th.Start(); } public static void ThreadAction() { while (true) { try { System.Threading.Thread.Sleep(3000); StreamWriter fs = System.IO.File.AppendText("c:\\microservice\\log.txt"); //开始写入 fs.WriteLine(string.Format("WinS {0}", DateTime.Now)); fs.Close(); } catch { } } }
时间: 2024-11-06 15:09:42