I have tried to find a solution to this problem but I did not find or did not know, I'm new at C#
I found a lot of solutions that talk about (invoke) but I did not know how to fix them on my code ,Everything if find is just a solution for label or textbox, If possible solve the problem
"System.InvalidOperationException: 'Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.'"
for (int i = 0; i <= len - 1; i++)
{
if (i % 3 == 0)
{
split = proxy[proxy_counter].Split(':');
num.Rows.Add(numlist[i], 0, 0, split[0], split[1], split[2], split[3]);
proxy_counter++;
}
else
{
num.Rows.Add(numlist[i], 0, 0, split[0], split[1], split[2], split[3]);
}
}
The problem is on the
MessageBox.Show. You can't change UI from a background thread. in order to do that you need toInvoke(as you said) theMessageBox.Showfrom the Principal Thread.Change your MessageBox line for (assuming that that piece of code is inside a Windows Form):