#ifndef __MyuThreadBase_H__
#define __MyuThreadBase_H__

#include <mwlcommon.h>
#include "MyuThreadManager.h"

//	クラス宣言
class CMyuThreadBase
{
private:
	CMyuThreadManager m_threadMgr;

	//unsigned long PrivateThreadFunc(void *lpParam);
	static unsigned long PrivateThreadFunc(void *thisPointer);

protected:
	virtual bool ThreadFunc()=0;

public:
	//	コンストラクタ・デストラクタ
	CMyuThreadBase(){ }
	virtual ~CMyuThreadBase(){}

	bool StartThread();
	bool Execute(){ return StartThread(); }
	bool IsEnded();
	bool WaitEnd( DWORD dwTimeoutMs=INFINITE );
	bool ForceEnd();
};

/////////////////////////////////////////////////


//	クラス宣言
template <typename T> class TMyuThread : public T
{
private:
	CMyuThreadManager m_threadMgr;

	unsigned long PrivateThreadFunc(void *lpParam);
protected:
	//virtual bool ThreadFunc()=0;

public:
	//	コンストラクタ・デストラクタ
	TMyuThread(){ }
	virtual ~TMyuThread(){}

	bool StartThread();
	bool IsAlive();
	bool WaitEnd( DWORD dwTimeoutMs=INFINITE );
	bool ForceEnd();
};

//#define CMyuThread CMyuThreadBase
//#define CMyuTaskedThread CMyuThreadBase
//#define CMyuBackgroundProcesser CMyuThreadBase
typedef CMyuThreadBase CMyuBackgroundProcesser;

#endif//__MyuThreadBase_H__