I am facing numerous crashes in an application that is multithreaded.
By reading this MSDN page , a technical note, and this article on TLS , I realized that CWnd objects CWnd displayed in HWND in TLS (which is thread-dependent memory access).
I was going to separate everything that looks like CWnd stream-remote access and convert it to HWND links and then use ::PostMessage as the communication port.
But one of my colleagues really insisted that I just CWnd* in CWnd* threads, adopt the ::PostMessage policy, but use CWnd::GetSafeHwnd() or pMyCWnd->m_hWnd in external threads to restore the native HWND .
I claimed that I had never seen GetSafeHwnd() be thread safe, and that CWnd is in TLS, its value in a different thread is different.
I am wrong? MSDN explicitly uses the term " unexpected results" .
What is your point of view regarding calling CWnd::GetSafehwnd() or pMyCWnd->m_hWnd in external threads from the creator thread?
Do you have any MSDN documentation that says it is safe or not.
Stephane rolling
source share