private delegate void ClearContextClient();//代理 /// <summary> /// 用异步的方式清空文本内容(解决多线程调用UI的问题) /// </summary> public void ClearContext() { //等待异步 if (this.InvokeRequired) { ClearContextClient c = new ClearContextClient(ClearContext); this.Invoke(c);//通过代理调用刷新方法 } else { string[] sLines = this.Lines; string[] sNewLines = new string[2]; Array.Copy(sLines, 0, sNewLines, 0, sNewLines.Length); this.Lines = sNewLines; PrintLine(2); PrintPrompt(); } }
private delegate void ClearContextClient();//代理 /// <summary> /// 用异步的方式清空文本内容(解决多线程调用UI的问题) /// </summary> public void ClearContext() { //等待异步 if (this.InvokeRequired) { ClearContextClient c = new ClearContextClient(ClearContext); this.Invoke(c);//通过代理调用刷新方法 } else { string[] sLines = this.Lines; string[] sNewLines = new string[2]; Array.Copy(sLines,0,sNewLines,0,sNewLines.Length); this.Lines = sNewLines; PrintLine(2); PrintPrompt(); } }