Thread.h
Upload User: jnsxzc
Upload Date: 2007-01-03
Package Size: 25k
Code Size: 1k
Category:

Process-Thread

Development Platform:

Visual C++

  1. // Thread.h: interface for the CThread class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_THREAD_H__65C44176_9AA3_11D3_8D3F_00105AAA7BB6__INCLUDED_)
  5. #define AFX_THREAD_H__65C44176_9AA3_11D3_8D3F_00105AAA7BB6__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. class CThread  
  10. {
  11. public:
  12. CThread();
  13. virtual ~CThread();
  14. // Calling thread waits for target thread to terminate.
  15. virtual void join();
  16. // Calling thread shuts down the target thread.  
  17. virtual void shutdown();
  18. protected:
  19. // Override this method to provide functionality to your thread.
  20. // This method is the content of the thread
  21. virtual void run();
  22. HANDLE m_hShutdownEvent; // shutdown event to be monitored by the thread
  23. unsigned long m_lThreadId; // Thread's ID
  24. private:
  25. // Disallow copies of thread via copy and assignment
  26. CThread(const CThread&);
  27. operator=(const CThread&);
  28. HANDLE m_hThread; // Thread's handle ... has all access permissions
  29. static void ThreadStart(void * argument); // startup routine callable from WIN32 thread library
  30. };
  31. #endif // !defined(AFX_THREAD_H__65C44176_9AA3_11D3_8D3F_00105AAA7BB6__INCLUDED_)