Fixed GUI unresponsiveness when acknowledging large number of alarms
authorVictor Kirhenshtein <victor@netxms.org>
Fri, 29 Apr 2005 12:15:05 +0000 (12:15 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Fri, 29 Apr 2005 12:15:05 +0000 (12:15 +0000)
ChangeLog
src/console/win32/AlarmBrowser.cpp

index 8734d09..9d20314 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
 - Fixed deadlock in status poller
 - Fixed incorrect socket handling in AgentConnection class
 - Fixed sorting bug in Windows console alarm browser
+- Fixed GUI unresponsiveness when acknowledging large number of alarms
 
 
 *
index d2c0837..1a0e9c3 100644 (file)
@@ -418,6 +418,20 @@ void CAlarmBrowser::OnContextMenu(CWnd* pWnd, CPoint point)
 }
 
 
+//
+// Alarm acknowlegement worker function
+//
+
+static DWORD AcknowlegeAlarms(DWORD dwNumAlarms, DWORD *pdwAlarmList)
+{
+   DWORD i, dwResult = RCC_SUCCESS;
+
+   for(i = 0; (i < dwNumAlarms) && (dwResult == RCC_SUCCESS); i++)
+      dwResult = NXCAcknowlegeAlarm(g_hSession, pdwAlarmList[i]);
+   return dwResult;
+}
+
+
 //
 // WM_COMMAND::ID_ALARM_ACKNOWLEGE message handler
 //
@@ -425,14 +439,23 @@ void CAlarmBrowser::OnContextMenu(CWnd* pWnd, CPoint point)
 void CAlarmBrowser::OnAlarmAcknowlege() 
 {
    int iItem;
+   DWORD i, dwNumAlarms, *pdwAlarmList, dwResult;
+
+   dwNumAlarms = m_wndListCtrl.GetSelectedCount();
+   pdwAlarmList = (DWORD *)malloc(sizeof(DWORD) * dwNumAlarms);
 
    iItem = m_wndListCtrl.GetNextItem(-1, LVNI_SELECTED);
-   while(iItem != -1)
+   for(i = 0; (iItem != -1) && (i < dwNumAlarms); i++)
    {
-      DoRequestArg2(NXCAcknowlegeAlarm, g_hSession, 
-                    (void *)m_wndListCtrl.GetItemData(iItem), _T("Acknowleging alarm..."));
+      pdwAlarmList[i] = m_wndListCtrl.GetItemData(iItem);
       iItem = m_wndListCtrl.GetNextItem(iItem, LVNI_SELECTED);
    }
+
+   dwResult = DoRequestArg2(AcknowlegeAlarms, (void *)dwNumAlarms, pdwAlarmList,
+                            _T("Acknowleging alarm..."));
+   if (dwResult != RCC_SUCCESS)
+      theApp.ErrorBox(dwResult, _T("Cannot acknowlege alarm: %s"));
+   free(pdwAlarmList);
 }
 
 void CAlarmBrowser::OnUpdateAlarmAcknowlege(CCmdUI* pCmdUI)