#pragma once
#include <xtl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>

#define QUOTEME(x) #x
#define xprintf

#define AttachThread(x) \
	xprintf("AttachFunc: %s\r\n",QUOTEME(x)); \
	m_sFuncName=QUOTEME(x);\
	AttachFunc(x);

class CThread
{
public:
	CThread(void);

	~CThread(void);

	void AttachFunc( LPTHREAD_START_ROUTINE lpThreadFunc );

	virtual HRESULT Stop();
	virtual HRESULT RunThread();
	virtual DWORD getExitCode();

	/**
	Sample
	**/
	static DWORD WINAPI CThread::Sample(void * Obj);
	
protected:
	std::string m_sFuncName;
private:
	LPTHREAD_START_ROUTINE m_pThreadFunc;
	HANDLE m_hThread;

	DWORD m_dThreadId;
};
