Home > Asp.Net, IT technique > Cross-thread operation not valid

Cross-thread operation not valid

February 20th, 2010 Arale Leave a comment Go to comments

解决方案1: Control.CheckForIllegalCrossThreadCalls = false;

解决方案2:

private void button1_Click(object sender, EventArgs e)
{

Thread thread = new Thread(new ThreadStart(CallModiMethod));
thread.Start();
}
private void CallModiMethod()
{
ModiControl("Hello Cross Thread Operation");
}

private delegate void ModiControlDelegate(string value);
private void ModiControl(string value)
{
if (label1.InvokeRequired)
{
label1.Invoke(new ModiControlDelegate(this.ModiControl), value);
}
else
{
label1.Text = value;
}
}


related post

Categories: Asp.Net, IT technique Tags:
  1. No comments yet.
  1. No trackbacks yet.