メンバー関数のマルチスレッドは少し細工が必要なので
プログラム例を載せます。
★Key.h
class Key
{
private:
HANDLE hThreadKanon;
static unsigned int __stdcall ThreadKanon(void *p);
void Kanon();
public:
Key();
~Key();
}
★Key.cpp
Key::Key()
{
hThreadKanon = (HANDLE)_beginthreadex(NULL, 0, &Key::ThreadKanon, this, 0, NULL);
}
Key::~Key()
{
WaitForSingleObject(hThreadKanon, INFINITE);
CloseHandle(hThreadKanon);
}
unsigned int __stdcall Key::ThreadKanon(void *p)
{
Key* pThis = (Key*)p;
pThis->Kanon();
_endthreadex(0);
return 0;
}
void Key::Kanon()
{
//実処理
}
お、久しぶりに記事書いてくれたんですね。
返信削除何の処理なのか分かりませんが今後も
記事楽しみにしてます^^
プログラムの説明無しとか、ほとんど私的メモですね。
返信削除次は違う話題を(^_^;)