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.

66 lines
2.4 KiB

  1. //=============================================================================
  2. // File: thread.h
  3. // Author: a-jammar
  4. //
  5. // Copyright (c) 1998-1999 Microsoft Corporation
  6. //
  7. // This header file defines the class used to perform threaded refreshes in
  8. // MSInfo (added late in the game). All refreshes should use this class.
  9. //=============================================================================
  10. #pragma once
  11. class CFolder;
  12. class CSystemInfo;
  13. class CDataGatherer;
  14. //-----------------------------------------------------------------------------
  15. // This structure is used to communicate with the thread function. A pointer is
  16. // passed when the thread function is called. We declare a static instance of
  17. // the struct which will be reused.
  18. //-----------------------------------------------------------------------------
  19. class CThreadingRefresh;
  20. struct SThreadInfo
  21. {
  22. volatile BOOL m_fShowData;
  23. volatile BOOL m_fCancel; // cancel the current refresh, stay in thread
  24. volatile BOOL m_fQuit; // exit the thread
  25. volatile BOOL m_fRecursive; // refresh folders recursively
  26. volatile BOOL m_fSoftRefresh; // if TRUE, don't force a refresh on existing data
  27. CFolder * m_pFolder; // the folder to refresh
  28. CSystemInfo * m_pSysInfo; // CSystemInfo to update when complete
  29. CDataGatherer * m_pGatherer; // use this to refresh the data
  30. CThreadingRefresh * m_pThreadRefresh;
  31. HANDLE m_eventDone; // refresh thread fires when done
  32. HANDLE m_eventStart; // main thread fires when more data
  33. };
  34. //static SThreadInfo threadinfo;
  35. class CThreadingRefresh
  36. {
  37. public:
  38. CThreadingRefresh(CDataGatherer * pGatherer);
  39. ~CThreadingRefresh();
  40. BOOL IsRefreshing();
  41. int PerchentageComplete();
  42. void RefreshAll(CFolder * pFolder, volatile BOOL * pfCancel = NULL);
  43. void RefreshFolder(CFolder * pFolder, BOOL fRecursive = FALSE, BOOL fSoftRefresh = FALSE);
  44. void RefreshFolderAsync(CFolder * pFolder, CSystemInfo * pSysInfo, BOOL fRecursive = FALSE, BOOL fSoftRefresh = FALSE);
  45. void CancelRefresh(BOOL fUpdateUI = TRUE);
  46. void KillRefreshThread();
  47. BOOL WaitForRefresh();
  48. BOOL ResultsPaneNotAvailable();
  49. void EnterCriticalSection() { ::EnterCriticalSection(&m_csThreadRefresh); };
  50. void LeaveCriticalSection() { ::LeaveCriticalSection(&m_csThreadRefresh); };
  51. private:
  52. CDataGatherer * m_pGatherer;
  53. HANDLE m_hThread;
  54. DWORD m_dwThreadID;
  55. SThreadInfo * m_pThreadInfo;
  56. CRITICAL_SECTION m_csThreadRefresh;
  57. };