Export (0) Print
Expand All
MFC
TRY
Expand Minimize
2 out of 9 rated this helpful - Rate this topic

AfxGetThread 

Call this function to get a pointer to the CWinThread object representing the currently executing thread.


CWinThread* AfxGetThread( );

Pointer to the currently executing thread; otherwise NULL.

Must be called from within the desired thread.

NoteNote

If you are porting an MFC project calling AfxGetThread from Visual C++ versions 4.2, 5.0, or 6.0, AfxGetThread calls AfxGetApp if no thread is found. In Visual C+ .NET and later, AfxGetThread returns NULL if no thread was found. If you want the application thread, you must call AfxGetApp.

//Print the current thread ID in the Debug Window
TRACE("Current Thread ID = 0x%X\n", AfxGetThread()->m_nThreadID);
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.