simple question
-
Excute a class as a thread Class name:
CTest
i was thinking of something like this:AfxBeginThread(CTest, THREAD_PRIORITY_NORMAL);
but it gives the error:error C2275: 'CTest': illegal use of this type as an expression
if i can't excute a class what does this mean:CWinThread* AfxBeginThread( CRuntimeClass* pThreadClass, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );
(source: MSDN) []D [] []D [] -
Excute a class as a thread Class name:
CTest
i was thinking of something like this:AfxBeginThread(CTest, THREAD_PRIORITY_NORMAL);
but it gives the error:error C2275: 'CTest': illegal use of this type as an expression
if i can't excute a class what does this mean:CWinThread* AfxBeginThread( CRuntimeClass* pThreadClass, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );
(source: MSDN) []D [] []D []There's two ways of using AfxBeginThread: Either you call if for a thread procedure, declared as
UINT MyThreadProc(LPVOID lParam)
{
...
}or you use it by providing a class derived from CWinThread as first parameter. While the former is used as a worker thread, that means doing some stuff, the latter is usually used for gui tasks. You should have a look at MSDN to get more information about that.
-
Excute a class as a thread Class name:
CTest
i was thinking of something like this:AfxBeginThread(CTest, THREAD_PRIORITY_NORMAL);
but it gives the error:error C2275: 'CTest': illegal use of this type as an expression
if i can't excute a class what does this mean:CWinThread* AfxBeginThread( CRuntimeClass* pThreadClass, int nPriority = THREAD_PRIORITY_NORMAL, UINT nStackSize = 0, DWORD dwCreateFlags = 0, LPSECURITY_ATTRIBUTES lpSecurityAttrs = NULL );
(source: MSDN) []D [] []D []The class must be derived from CWinThread and must override the method
BOOL CreateThread(DWORD, UINT, LPSECURITY_ATTRIBUTES);
and when passing the runtime class of class use the macroRUNTIME_CLASS(classname)
much better, unless you really need it, use theAfxBeginThread()
to execute a function and pass the class object's pointer as the function's parameter. if you have VC++.Net then read these links in the msdn ms-help://MS.VSCC/MS.MSDNVS/vccore/html/_core_Multithreading.3a_.Creating_Worker_Threads.htm ms-help://MS.VSCC/MS.MSDNVS/vccore/html/_core_Multithreading.3a_.Creating_User.2d.Interface_Threads.htm