From a4fe507adf68302124bfc732ac11abde946e52cd Mon Sep 17 00:00:00 2001 From: Mihaela Stoica Date: Fri, 10 Oct 2014 13:16:50 +0100 Subject: [PATCH] CA-147941: Fixed the RPU wizard hang in "Reconnecting Storage" and connecting action stuck in progress state In some cases calling Control.Invoke() from a background thread causes that thread to go in a "sleep, wait, or join" mode, while waiting for Invoke to happen, although the UI thread is running normally. If the Control is the MainWindow, it works as expected, but we've seen it happening while connecting or disconnecting from a large pool, on calling Invoke on controls like NavigationView, AlertSummaryPage, HistoryPage, etc. To fix this, we call the Invoke on the MainWindow in all the places where we've seen the issue. With this changes, the previous fix for CA-148245 (call RequestRefreshTreeView on CacheClearing event) is not needed anymore, so I removed that call. Signed-off-by: Mihaela Stoica --- .../Controls/FilterLocationToolStripDropDownButton.cs | 4 ++-- XenAdmin/Controls/MainWindowControls/NavigationView.cs | 4 ++-- XenAdmin/TabPages/AlertSummaryPage.cs | 6 +++--- XenAdmin/TabPages/HistoryPage.cs | 4 ++-- XenAdmin/TabPages/ManageUpdatesPage.cs | 8 ++++---- .../RollingUpgradeWizard/RollingUpgradeUpgradePage.cs | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/XenAdmin/Controls/FilterLocationToolStripDropDownButton.cs b/XenAdmin/Controls/FilterLocationToolStripDropDownButton.cs index 31285d535..47d3aa4e1 100644 --- a/XenAdmin/Controls/FilterLocationToolStripDropDownButton.cs +++ b/XenAdmin/Controls/FilterLocationToolStripDropDownButton.cs @@ -286,12 +286,12 @@ namespace XenAdmin.Controls private void connection_ConnectionStateChanged(object sender, EventArgs e) { - Program.Invoke(Parent, RefreshLists); + Program.Invoke(Program.MainWindow, RefreshLists); } private void connection_CachePopulated(object sender, EventArgs e) { - Program.Invoke(Parent, RefreshLists); + Program.Invoke(Program.MainWindow, RefreshLists); } private void XenConnections_CollectionChanged(object sender, CollectionChangeEventArgs e) diff --git a/XenAdmin/Controls/MainWindowControls/NavigationView.cs b/XenAdmin/Controls/MainWindowControls/NavigationView.cs index d14293291..3850ebcc9 100644 --- a/XenAdmin/Controls/MainWindowControls/NavigationView.cs +++ b/XenAdmin/Controls/MainWindowControls/NavigationView.cs @@ -313,7 +313,7 @@ namespace XenAdmin.Controls.MainWindowControls public void RequestRefreshTreeView() { - Program.BeginInvoke(this, treeViewUpdateManager.RequestUpdate); + Program.BeginInvoke(Program.MainWindow, treeViewUpdateManager.RequestUpdate); } private void SuspendRefreshTreeView() @@ -345,7 +345,7 @@ namespace XenAdmin.Controls.MainWindowControls if (Disposing || IsDisposed || Program.Exiting) return; - Program.Invoke(this, () => + Program.Invoke(Program.MainWindow, () => { if (ignoreRefreshTreeView > 0) { diff --git a/XenAdmin/TabPages/AlertSummaryPage.cs b/XenAdmin/TabPages/AlertSummaryPage.cs index 17edf8a3f..708bd692a 100644 --- a/XenAdmin/TabPages/AlertSummaryPage.cs +++ b/XenAdmin/TabPages/AlertSummaryPage.cs @@ -139,7 +139,7 @@ namespace XenAdmin.TabPages // 4) Take the top n as set by the filters // 5) Add them to the control using the optimized AddRange() - Program.Invoke(this, SetFilterLabel); + Program.Invoke(Program.MainWindow, SetFilterLabel); List alerts = Alert.NonDismissingAlerts; alerts.RemoveAll(FilterAlert); @@ -179,7 +179,7 @@ namespace XenAdmin.TabPages alerts.RemoveRange(ALERT_CAP, alerts.Count - ALERT_CAP); } - Program.Invoke(this, delegate + Program.Invoke(Program.MainWindow, delegate { List gridRows = new List(); log.Debug("Rebuilding alertList: Adding alert rows"); @@ -282,7 +282,7 @@ namespace XenAdmin.TabPages private bool FilterAlert(Alert alert) { bool hide = false; - Program.Invoke(this, () => + Program.Invoke(Program.MainWindow, () => hide = toolStripDropDownButtonDateFilter.HideByDate(alert.Timestamp.ToLocalTime()) || toolStripDropDownButtonServerFilter.HideByLocation(alert.HostUuid) || toolStripDropDownSeveritiesFilter.HideBySeverity(alert.Priority)); diff --git a/XenAdmin/TabPages/HistoryPage.cs b/XenAdmin/TabPages/HistoryPage.cs index 10d22f315..ebe275c35 100644 --- a/XenAdmin/TabPages/HistoryPage.cs +++ b/XenAdmin/TabPages/HistoryPage.cs @@ -121,7 +121,7 @@ namespace XenAdmin.TabPages if (asyncAction != null) asyncAction.RecomputeCanCancel(); - Program.Invoke(this, () => + Program.Invoke(Program.MainWindow, () => { var row = FindRowFromAction(sender); if (row != null) @@ -203,7 +203,7 @@ namespace XenAdmin.TabPages private bool FilterAction(ActionBase action) { bool hide = false; - Program.Invoke(this, () => + Program.Invoke(Program.MainWindow, () => hide = toolStripDdbFilterDates.HideByDate(action.Started) || toolStripDdbFilterLocation.HideByLocation(action.GetApplicableHosts()) || toolStripDdbFilterStatus.HideByStatus(action)); diff --git a/XenAdmin/TabPages/ManageUpdatesPage.cs b/XenAdmin/TabPages/ManageUpdatesPage.cs index 532b8895a..c88fa980d 100644 --- a/XenAdmin/TabPages/ManageUpdatesPage.cs +++ b/XenAdmin/TabPages/ManageUpdatesPage.cs @@ -84,12 +84,12 @@ namespace XenAdmin.TabPages private void UpdatesCollectionChanged(object sender, EventArgs e) { - Program.Invoke(this, Rebuild); + Program.Invoke(Program.MainWindow, Rebuild); } private void CheckForUpdates_CheckForUpdatesStarted() { - Program.Invoke(this, () => + Program.Invoke(Program.MainWindow, () => { checksQueue++; if (checksQueue > 1) @@ -106,7 +106,7 @@ namespace XenAdmin.TabPages private void CheckForUpdates_CheckForUpdatesCompleted(bool succeeded, string errorMessage) { - Program.Invoke(this, delegate + Program.Invoke(Program.MainWindow, delegate { checksQueue--; toolStripButtonRefresh.Enabled = true; @@ -258,7 +258,7 @@ namespace XenAdmin.TabPages hosts = serverUpdate.DistinctHosts.Select(h => h.uuid).ToList(); bool hide = false; - Program.Invoke(this, () => + Program.Invoke(Program.MainWindow, () => hide = toolStripDropDownButtonDateFilter.HideByDate(alert.Timestamp.ToLocalTime()) || toolStripDropDownButtonServerFilter.HideByLocation(hosts)); return hide; diff --git a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs index 8213871df..3d1e653fa 100644 --- a/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs +++ b/XenAdmin/Wizards/RollingUpgradeWizard/RollingUpgradeUpgradePage.cs @@ -421,7 +421,7 @@ namespace XenAdmin.Wizards.RollingUpgradeWizard foreach (DataGridViewRowUpgrade row in rowsForHost) { DataGridViewRowUpgrade closureRow = row; - Program.Invoke(this, () => closureRow.UpdateStatus(HostUpgradeState.Upgrading, plan.Status)); + Program.Invoke(Program.MainWindow, () => closureRow.UpdateStatus(HostUpgradeState.Upgrading, plan.Status)); } }