Showing posts with label Control. Show all posts
Showing posts with label Control. Show all posts

Friday, February 8, 2008

Cross Thread Operation Not Valid

Cross thread operation not valid is a problem that we encounter when we work with threads.This problem has been mentioned by many.So including the code for the same.It might be of use to somebody.

delegate void InfoMessageLabel(String info);

public void UpdateLabelText(String info)
{
if (_loaderMessageLabel.InvokeRequired)
{
InfoMessageLabel method = new InfoMessageLabel(UpdateLabelText);
_loaderMessageLabel.Invoke(method, new object[] { info });
return;
}

_loaderMessageLabel.Text = info;
}