1.委托
1 #region 委托 2 /// <summary> 3 /// 输出委托 4 /// </summary> 5 /// <param name="msg"></param> 6 private delegate void OutputDelegate(string msg); 7 8 /// <summary> 9 /// 清空委托 10 /// </summary> 11 private delegate void ClearDelegate(); 12 13 /// <summary> 14 /// 文本框输出委托 15 /// </summary> 16 /// <param name="msg"></param> 17 private void TextBoxOutput(string msg) 18 { 19 if (ConfigCon.IsVisble==false) 20 { 21 this.textBox1.Dispatcher.Invoke(new OutputDelegate(OutputAction), msg); 22 23 this.textBox1.Dispatcher.Invoke(new ClearDelegate(ClearAction)); 24 25 } 26 27 } 28 29 /// <summary> 30 /// 文本框输出内容 31 /// </summary> 32 /// <param name="msg"></param> 33 private void OutputAction(string msg) 34 { 35 this.textBox1.AppendText(msg + "\n"); 36 // this.textBox1.AppendText("\n"); 37 this.textBox1.ScrollToEnd(); 38 } 39 40 41 /// <summary> 42 /// 文本框清空 43 /// </summary> 44 private void ClearAction() 45 { 46 47 if (this.textBox1.LineCount > 10000 * 1) 48 { 49 this.textBox1.Clear(); 50 } 51 52 53 } 54 55 #endregion