- private delegate void myUICallBack_ControlText(string myStr, Control ctl);
- private void ChangeControlText(string myStr, Control ctl)
- {
- if (this.InvokeRequired)
- {
- myUICallBack_ControlText myUpdate = new myUICallBack_ControlText(ChangeControlText);
- this.Invoke(myUpdate, myStr, ctl);
- }
- else
- {
- ctl.Text = myStr;
- }
- }
呼叫
- ChangeControlText("新的Text" , label1 );
- private delegate void myUICallBack_Enable(bool boo, System.Windows.Forms.Timer timer);
- private void TimerIO(bool boo, System.Windows.Forms.Timer timer)
- {
- if (this.InvokeRequired)
- {
- myUICallBack_Enable myUpdate = new myUICallBack_Enable(TimerIO);
- this.Invoke(myUpdate, boo, timer);
- }
- else
- {
- timer.Enabled = boo;
- }
- }
呼叫
- TimerIO( true , timer1 );