Home
>
Windows Forms > Cross-Threading Component Update
Cross-Threading Component Update
September 5th, 2009
admin
public void TextComponentUpdate(String text, Object source)
{
try
{
// Checks if the call for GUI update is from different thread
if (this.InvokeRequired)
{
CrossThreadingTextUpdate callback = new CrossThreadingTextUpdate(TextComponentUpdate);
this.Invoke(callback, text, source);
}
else
{
if (source.ToString().Equals("lbStatus"))
{
if (text.Equals("Clear"))
this.lbStatus.Items.Clear();
}
else
{
this.lbStatus.Items.Add(text);
}
}
}
}
catch (Exception ex)
{
TextComponentUpdate(ex.Message.ToString(), "lbStatus");
}
}
delegate void CrossThreadingTextUpdate(String text, Object source);