WPF 定时写入文本
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 { } } }
"唯有高屋建瓴,方可水到渠成"