日期:2014-05-18 浏览次数:21084 次
private int i = 0; private delegate void InvokeLabel(); private delegate void InvokeMainForm(); private void Form_Load(object sender, EventArgs e){ Thread setLabelTextThread = new Thread(setLabelText); setLabelTextThread.Start(); this.backgroundWorker.RunWorkerAsync(); } private void setLabelText() { InvokeLabel il = delegate(){ this.lable1.Text = i++.toString(); }; this.Invoke(il); } private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e){ while(true){ InvokeMainForm imf = delegate(){ mainForm = new MainForm(); }; this.Invoke(imf); } }
this.Invoke改成this.BeginInvoke
------解决方案--------------------