首页 > 代码库 > WPF 定时写入文本

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 { }    }}

  

WPF 定时写入文本