61 lines
1.7 KiB
C++
61 lines
1.7 KiB
C++
// ThinThread.h : header file
|
|
// Copyright (C) 1997 by The Windward Group, All Rights Reserved
|
|
|
|
#ifndef THINTHREAD_H
|
|
#define THINTHREAD_H
|
|
|
|
#ifndef __AFXWIN_H__
|
|
#error include 'stdafx.h' before including this file for PCH
|
|
#endif
|
|
|
|
#include <afxmt.h>
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
class CThinThread
|
|
{
|
|
public:
|
|
CThinThread();
|
|
virtual ~CThinThread();
|
|
|
|
BOOL CreateThread(DWORD dwCreateFlags = 0,
|
|
UINT nStackSize = 0,
|
|
LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL,
|
|
UINT nMilliSecs = INFINITE, // upper time limit to wait
|
|
UINT Type = 0);
|
|
|
|
HANDLE GetHandle() {return m_hThread2;}
|
|
BOOL IsBusy() {return m_b2ndThread;}
|
|
void Stop() {m_bEndThread = TRUE;}
|
|
|
|
void Finalize();
|
|
|
|
protected:
|
|
int m_nCycleTime; // do work cycle time
|
|
|
|
CEvent* m_pWorkEvent; // do work event
|
|
CEvent* m_pExitEvent; // used to synchronize destruction
|
|
BOOL m_bEndThread; // end the thread ?
|
|
BOOL m_b2ndThread; // 2nd thread active?
|
|
|
|
CEvent* m_pWorkEvent2; // do work event
|
|
HANDLE m_hThread2; // 2nd thread handle
|
|
BOOL m_b3rdThread; // 3rd thread active?
|
|
HANDLE m_hThread3; // 3rd thread handle
|
|
|
|
virtual void StartWork() {} // override to do startup
|
|
virtual void DoWork(UINT ThreadType) {}; // override to do work
|
|
virtual void EndWork() {} // override to do shutdown
|
|
|
|
CEvent* GetEvent() const {return m_pWorkEvent;} // cycle control event
|
|
int GetCycleTime() const {return m_nCycleTime;}
|
|
void KillThread2();
|
|
int Run(UINT ThreadType);
|
|
void SetCycleTime(int nMilliSecs) {m_nCycleTime = nMilliSecs;}
|
|
|
|
// static unsigned int __stdcall Start(void* pv);
|
|
static DWORD WINAPI Start(LPVOID pv);
|
|
static DWORD WINAPI Start2(LPVOID pv);
|
|
|
|
};
|
|
#endif
|