Hi I am trying to update my listbox asyncronously, so it wouldnt freeze for one sec while updating, unfortunately it throws an exception
My code
private async void timer1_Tick(object sender, EventArgs e) {
await Task.Run(() =>
{
listBox1.DataSource = listboxitems;
listBox1.TopIndex = listBox1.Items.Count - 1;
});
}
Exception
System.Reflection.TargetInvocationException:
InvalidOperationException: Invalid cross-thread operation: the listBox1 control was accessed by a different thread
than the thread for which it was created.
Anyone got a clue, how can I fix this ?