The UI thread hangs occasionally at the statement 'if (this.InvokeRequired)' in the following method.
Can you help me to identify the cause of the issue
public void OnModuleInitializationCompleted(object sender, EventArgs e)
{
ModuleStatusWindow.Logger.LogMessage("OnModuleInitializationCompleted", LogMessageType.Information, "Received {0}", (sender as IModule).Name);
if (this.InvokeRequired)
{
this.BeginInvoke(new ECEventsHandler(OnModuleInitializationCompleted), sender, e);
}
else
{
CheckIfAllModulesInitComplete();
}
}
private void CheckIfAllModulesInitComplete()
{
ModuleStatusWindow.Logger.LogMessage("CheckIfAllModulesInitComplete", LogMessageType.Information, "Enter >>");
this._moduleStatusGrid.DataSource = this._moduleDataList.ToArray();
this._moduleStatusGrid.Invalidate();
ModuleStatusWindow.Logger.LogMessage("CheckIfAllModulesInitComplete", LogMessageType.Information, "Updated grid control...");
if (this._moduleDataList.Count(moduleData => !moduleData.IsInitOver) == 0)
{
this._footprint.DeActivate();
ModuleStatusWindow.Logger.LogMessage("CheckIfAllModulesInitComplete", LogMessageType.Information, "Stopping message listenr...");
ClientMessageListner.Stop();
ModuleStatusWindow.Logger.LogMessage("CheckIfAllModulesInitComplete", LogMessageType.Information, "Closing Window...");
this.Close();
}
ModuleStatusWindow.Logger.LogMessage("CheckIfAllModulesInitComplete", LogMessageType.Information, "Leave <<");
}
More than likely, you have some kind of race condition which is resulting in a deadlock. Or, your debugging information is messed up and that's not really the line that is blocking.