I am updating a “timer” field in my listView from different threads. It works fine, the problem is just that it flickers. This is the code each thread is calling when it needs to be updated (almost every second).
private void AddToListView(string user, string status, string proxy, int number)
{
Invoke(new MethodInvoker(
delegate
{
listView1.BeginUpdate();
this.listView1.Items[number].SubItems[1].Text = status;
listView1.EndUpdate();
}
));
}
Having Googled a bit im not even sure i can make this flicker go away? :/
I would not use
Invokehere. In fact, in most cases it is usually not a great option despite what you may read on the internet. Instead, package up the data being generated by the thread into a POCO and put it into a queue. Have aSystem.Windows.Forms.Timertick every second with the event handler pulling items out of the queue to update theListViewin batches. Also, try settingDoubleBufferedto true. These suggestions should help some.