Note that there are some explanatory texts on larger screens.

plurals
  1. POCan a class have multiple thread function?
    primarykey
    data
    text
    <p>I wrote a class that can do some work in another thread:</p> <pre><code> class SkeData { public: SkeData(INuiSensor* pSensor); ~SkeData(); HANDLE StartSaveSkeData_Frames(int nFrames = 1); HANDLE StartSaveSkeData2File_Frames(HANDLE hFile,int nFrames = 1); [...] private: //Two thread functions static DWORD WINAPI AddFrames(LPVOID lpParam); static DWORD WINAPI AddFrames2File(LPVOID lpParam); [...] }; HANDLE SkeData::StartSaveSkeData_Frames(int nFrames) { [...] m_hThread = CreateThread(NULL, 0, AddFrames, this, 0, NULL); return m_hThread; } HANDLE SkeData::StartSaveSkeData2File_Frames(HANDLE hFile,int nFrames) { [...] m_hThread = CreateThread(NULL, 0, AddFrames2File, this, 0, NULL); return m_hThread; } DWORD WINAPI SkeData::AddFrames(LPVOID lpParam) { SkeData *This = (SkeData *)lpParam; return This-&gt;Thread_AddFrames(); } DWORD WINAPI SkeData::AddFrames2File(LPVOID lpParam) { SkeData *This = (SkeData *)lpParam; return This-&gt;Thread_AddFrames2File(); } When I built the program solution in VS2010, linking error came up like this: SkeData.obj : error LNK2019: unresolved external symbol "private: unsigned long __thiscall SkeData::Thread_AddFrames2File(void)" (?Thread_AddFrames2File@SkeData@@AAEKXZ) referenced in function "private: static unsigned long __stdcall SkeData::AddFrames2File(void *)" (?AddFrames2File@SkeData@@CGKPAX@Z) 1&gt;E:\***\DataCollection.exe : fatal error LNK1120: 1 unresolved externals 1&gt; 1&gt;Build FAILED. </code></pre> <p>However, when I removed one of the thread functions, it can be successfully built. Thus I guess the reason to the error is something about the thread function. But I still don't understand why I can not add one more thread function in my class???</p> <p>I hope anyone can give more explanations.</p> <p>Thank you!</p> <p>More: Sorry there's something wrong when I pasted my code..I did implement both of the thread functions...And if I didn't, the error will not be like this ,right?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload