I try to add a row to a listView
listView1.Items.AddRange(new ListViewItem[] { item1 });
from a different thread to the one in which it was created and it throws an Exception.
Can anyone help me understand how to do this correctly?
You can use Control.Invoke()
to execute your code back on the UI thread:
listView1.Invoke(
new MethodInvoker(delegate(){
listView1.Items.AddRange(new ListViewItem[] { item1 };
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With