Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.0 KiB

  1. //=============================================================================
  2. // Define the classes and functions used to manage threaded WMI refreshes.
  3. //=============================================================================
  4. #pragma once
  5. #include "category.h"
  6. class CRefreshThread
  7. {
  8. friend DWORD WINAPI ThreadRefresh(void * pArg);
  9. public:
  10. CRefreshThread(HWND hwnd);
  11. ~CRefreshThread();
  12. void StartRefresh(CMSInfoLiveCategory * pCategory, BOOL fRecursive = FALSE, BOOL fForceRefresh = FALSE);
  13. void CancelRefresh();
  14. void KillRefresh();
  15. BOOL IsRefreshing();
  16. BOOL WaitForRefresh();
  17. void EnterCriticalSection() { ::EnterCriticalSection(&m_criticalsection); };
  18. void LeaveCriticalSection() { ::LeaveCriticalSection(&m_criticalsection); };
  19. BOOL GetForceRefresh() { return m_fForceRefresh; };
  20. HRESULT CheckWMIConnection();
  21. void GetRefreshStatus(LONG * pCount, CString * pstrCurrent)
  22. {
  23. ::EnterCriticalSection(&m_csCategoryRefreshing);
  24. *pCount = m_nCategoriesRefreshed;
  25. *pstrCurrent = m_strCategoryRefreshing;
  26. ::LeaveCriticalSection(&m_csCategoryRefreshing);
  27. };
  28. public:
  29. CMSInfoLiveCategory * m_pcategory; // category to refresh
  30. CString m_strMachine; // machine from which to gather data
  31. protected:
  32. volatile BOOL m_fCancel; // cancel the current refresh, stay in thread
  33. volatile BOOL m_fQuit; // exit the thread
  34. volatile BOOL m_fRecursive; // refresh categories recursively
  35. volatile BOOL m_fForceRefresh; // if TRUE, refigure all the cached data
  36. volatile LONG m_nCategoriesRefreshed; // number of categories refreshed
  37. CString m_strCategoryRefreshing; // category currently being refreshed
  38. CRITICAL_SECTION m_csCategoryRefreshing; // critical section to guard the string
  39. HANDLE m_eventDone; // refresh thread fires when done
  40. HANDLE m_eventStart; // main thread fires when more data
  41. CRITICAL_SECTION m_criticalsection;
  42. HRESULT m_hresult;
  43. HRESULT m_hrWMI;
  44. HWND m_hwnd;
  45. HANDLE m_hThread;
  46. DWORD m_dwThreadID;
  47. };