For the beginners, working on thread might come across the error saying “Cross-thread operation not valid“. This type error comes normally when Windows control created in one thread and accessed in another.
Because the Windows control are not thread safe by default.
The best way to solve this kind of error is :
if (InvokeRequired) { this.Invoke(new MethodInvoker(delegate { //Your code here, like set text box content or get text box contents etc.. })); } else { // Your code here, like set text box content or get text box contents etc.. // SAME CODE AS ABOVE }
Leave a Reply