private void GenerateFile() { ConfigSettings config = new ConfigSettings(); fffProcessor processor = new fffProcessor(config); processor.SetTargetFile(@"I:\5mm.txt"); processor.LoadStlFile(@"I:\5mm.stl"); processor.DoProcessing(); processor.finalize(); processor.Cancel(); using (System.IO.StreamReader sr = new System.IO.StreamReader(@"I:\5mm.txt")) { string str; while ((str = sr.ReadLine()) != null) { //在线程中更新UI(通过UI线程同步上下文m_SyncContext) m_SyncContext.Post(SetTextSafePost, str); } } }