Both are not valid options.
First one is big no-no. It makes things worse as it can conceal a real problem. An application can even run successfully many times and later fail, and the cause of the problem will be very hard to find, nearly impossible.
Second one is not an option at all. Let's see.
This is just a predicate which allows a code to select weather
System.Windows.Forms.Control.Invoke
or
System.Windows.Forms.Control.BeginInvoke
,
so the real option is using invocation, not InvokeRequired
.
You cannot call anything related to UI form a non-UI thread. You should always use invocation.
Now, what about
InvokeRequired
? It has limited need. First of all, it does not matter on which control
Invoke
or
BeginInvoke
can be called; it can be any control actually included in currently running UI be some UI thread. This predicate will
always return
true
if you call it from any other thread, and will
always return
false
if you call it in the
same UI thread. In most cases, you know that by design, without calling
InvokeRequired
. This call may be needed only if you have some method can sometimes be called from the same UI thread, sometime from some other thread(s).
See my past solution where I explain all that in detail:
Control.Invoke() vs. Control.BeginInvoke()[
^].
—SA