public Form1() { InitializeComponent(); //线程访问控件(不安全的方式) //TextBox.CheckForIllegalCrossThreadCalls = false; setTex = new DelegateSetText(SetText); }
private void UpdateUps(int ups) { if (InvokeRequired) { var d = new DelegateSetText(UpdateUps); Invoke(d, ups); } else { Text = $"Crystalshire - Authentication @ {ups} Ups"; } }
public Form1() { InitializeComponent(); textBox1.ScrollBars = ScrollBars.Vertical; SetTextBox1Text = new DelegateSetText((s) => { textBox1.Text = s; }); }
private void SetText(string text) { if (txtConsole.InvokeRequired) { DelegateSetText method = new DelegateSetText(SetText); this.Invoke(method, text); } else { txtConsole.Text += text+Environment.NewLine; } }