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.
You're calling Delegate.BeginInvoke
in button1_Click
, which means SayListeyeEkle
will be called in a thread-pool thread - which means it's entirely correct for InvokeRequired
to be true. It wouldn't be true if you called ListeyeEkle
directly from button1_Click
, in the UI thread.
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...