When i want to use delegate class to make call while windows form working, i always have to use InvokeRequired. It is ok. But who changed the InvokeReuqired property while it is working.
Please check this image:

When does the vaIue of the InvokeRequired property change?
1.1k Views Asked by uzay95 AtThere are 3 best solutions below
On
InvokeRequired is true when the control is accessed from a thread other than the thread it was created on, and false otherwise.
To more directly answer your question, it's not that the InvokeRequired property "changes" at a specific point in time; it's more accurate to say that it may return different values based on the thread you access it from.
On
What do you mean "change the InvokeRequired property" ? Do you mean that the true/false value is changing ? If it returns true, and you make the delegate call to BeginInvoke, then after that, in the delegate, the value better have changed. The whole point is to "switch" to the thread that the control was created on. When a line of code with InvokeRequired is executed on any thread other than the thread the control was created on, InvokeRequired will return true. Only when executed on the same thread the control was created on will it return false. The property could have been named
NotOnThreadIWasCreatedIn, cause thats really all it's doing. It's named InvokeRequired to coomunicate what it needs to be used for...
You're calling
Delegate.BeginInvokeinbutton1_Click, which meansSayListeyeEklewill be called in a thread-pool thread - which means it's entirely correct forInvokeRequiredto be true. It wouldn't be true if you calledListeyeEkledirectly frombutton1_Click, in the UI thread.