It sounds like you could be asking one of the following
- Given that this method runs in a background thread, within the methods
Invalidate
and Close
should I be checking the InvokeRequired
property?
- Given that this method runs in a background thread the
InvokeRequired
property will always return false
so should I just avoid checking it?
For #1 the answer is no. The methods Close
and Invalidate
don't have a responsibility to check the InvokeRequired
property. It is an implicit part of their contract that the InvokeRequired
property be false before they are called.
For #2, yes if it's always called on a background thread I would skip the check and just go straight to the Invoke
methods.
In either case I would rewrite the method as follows.
private void CheckIfAllModulesInitComplete()
{
MethodInvoker del = delegate {
this._moduleStatusGrid.Invalidate();
if (this._moduleDataList.Count(moduleData => !moduleData.IsInitOver) == 0)
{
this._footprint.DeActivate();
this.Close();
}
};
this.Invoke(del, null);
}