You must interact with a control on the UI thread.
You can use
Control.InvokeRequired[
^] to determine if you're on the UI tread or not. If you're not on the UI thread you have to use
Control.Invoke[
^] or
Control.BeginInvoke[
^]
In the case you posted using
Invoke
wouldn't make sense, but I guess this is not your real case, so you'll want to do something like the following
int j = i;
listBox1.Invoke(() => listBox1.Items.Add(j));