ActiveTest.cpp 789 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // ActiveTest.cpp
  3. //
  4. #include <afxwin.h>
  5. #include "ActiveTest.h"
  6. namespace CppUnit {
  7. // Spawn a thread to a test
  8. void ActiveTest::run(TestResult* result)
  9. {
  10. CWinThread* thread;
  11. setTestResult(result);
  12. _runCompleted.ResetEvent();
  13. thread = AfxBeginThread(threadFunction, this, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
  14. DuplicateHandle(GetCurrentProcess(), thread->m_hThread, GetCurrentProcess(), &_threadHandle, 0, FALSE, DUPLICATE_SAME_ACCESS);
  15. thread->ResumeThread();
  16. }
  17. // Simple execution thread. Assuming that an ActiveTest instance
  18. // only creates one of these at a time.
  19. UINT ActiveTest::threadFunction(LPVOID thisInstance)
  20. {
  21. ActiveTest* test = (ActiveTest*) thisInstance;
  22. test->run();
  23. test->_runCompleted.SetEvent();
  24. return 0;
  25. }
  26. } // namespace CppUnit