日期:2014-05-18 浏览次数:20959 次
/// <summary> private delegate void LoadFileDelegate(string path, RichTextBoxStreamType streamType); /// 加载文件 /// </summary> /// <param name="path"></param> public bool LoadFile(string path) { WaitForm waitForm = null; bool isSuc = true; RichTextBoxStreamType streamType = RichTextBoxStreamType.RichText; try { Thread thread = new Thread(new ThreadStart(delegate() { System.Threading.Thread.Sleep(200); LoadFileDelegate loadFileDelegate = new LoadFileDelegate(LoadFile); loadFileDelegate.BeginInvoke(path, streamType, result => { LoadFileDelegate loadFileDelegate2 = (LoadFileDelegate)result.AsyncState; loadFileDelegate2.EndInvoke(result); if (waitForm != null) { waitForm.Invoke(new MethodInvoker(delegate() { waitForm.Close(); waitForm.Dispose(); })); } }, loadFileDelegate); })); thread.Start(); waitForm = new WaitForm("正在导入文件,请稍侯..."); waitForm.ShowDialog(); //txtEditor.LoadFile(path, streamType); } catch (Exception ex) { LogFile.WriteLogInfo(ex.ToString(), "编辑器【加载文件】失败!"); isSuc = false; } return isSuc; } private void LoadFile(string path, RichTextBoxStreamType streamType) { this.BeginInvoke(new MethodInvoker(delegate() { txtEditor.LoadFile(path, streamType); })); }
private void LoadFile(string path, RichTextBoxStreamType streamType) { txtEditor.LoadFile(path, streamType); }
------解决方案--------------------
为什么要用多线程那么麻烦呢。。为什么要一次load 100m呢。。分页load,每次几十100k,秒杀多线程。。连wait都省了。。
------解决方案--------------------
我覺得你應該使用 AutoVue 20.2,這個能讀幾百種文檔,況且是java的api,速度很快,不假死
------解决方案--------------------