The first topic is What wrong with my InvokeRequied
I followed the answer that he recommended it to me but I found a new problem.
The result of below picture is cross thread exception.
What is wrong with my code ?
How to solve this problem ?

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to MSDN
InvokeRequiredcan returnfalseeven in cases whereInvokeRequiredshould betrue– namely in the case that you accessInvokeRequiredbefore theHandleof that control/form (or a parent of it) has been created.Basically your check is incomplete which leads to the result you see.
You need to check
IsHandleCreated– if that isfalsethen you would need to useInvoke/BeginInvokeregardless of whatInvokeRequiredreturns.[UPDATE]
BUT:
This usually won’t work robustly since
Invoke/BeginInvokecheck which thread createdHandleto do their magic…[/UPDATE]
Only if
IsHandleCreatedistrueyou act based on whatInvokeRequiredreturns – something along the lines of:[UPDATE]
Thus the following is important to avoid this problem
Always make sure that the
Handleis already created BEFORE the first access on a thread other than the UI thread.According to MSDN you just need to reference
control.Handlein the UI thread to force it being created – in your code this must happen BEFORE the very first time you access that control/form from any thread that is not the UI thread.[/UPDATE]