Possible Duplicate:
How to update GUI from another thread in C#?
My Timer event crashes because the events are called on a different thread
I have a timer object that I want to periodically update a UI control which is a label. However it crashes and says I need to update it on the UI thread. Can anyone help?
private void frmMain_Load(object sender, EventArgs e)
{
aTimer = new System.Timers.Timer(1000);
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Interval = 2000;
aTimer.Enabled = true;
}
public void updateUI()
{
lblAirTrack.Text = "Tracking: " + itemList.Count + " items";
}