All notes

MSDN: Safe, Simple Multithreading in Windows Forms.


StackOverflow: windows form on close do sth.

Handle the FormClosed event:

If you want to be able to prevent the form from closing, handle the FormClosing event instead, and set e.Cancel to true.


------ ### InvalidOperationException: call from a different thread References: * [] Method 1 ```csharp CheckForIllegalCrossThreadCalls = false; ``` Method 2 ```csharp //建立个委托 private delegate string returnStrDelegate(); //搞个最简单滴取值滴方法~ private string returnSchool() { return CB_School.SelectedValue.ToString(); } //判断一下是不是该用Invoke滴~,不是就直接返回~ private string returnCB(returnStrDelegate myDelegate) { if (this.InvokeRequired) { return (string)this.Invoke(myDelegate); } else { return myDelegate(); } } //别的线程里的调用哇~ string _school = returnCB(returnSchool); ```