Pass an MFC control to a thread or pass an handle? <p>I've been reading somewhere that it is safer to pass an MFC ui control to a thread as an handle rather than to pass a pointer to the control.</p> <p>Option 1 - pass a pointer to static text:</p> <pre><code>TestDialog dlg1; ::_beginthreadex(NULL, 0, &amp;tSetTextByPointer, &amp;dlg1.m_StaticText, 0, NULL); dlg1.DoModal(); UINT WINAPI tSetTextByPointer(LPVOID arg) { CStatic * pStaticText = static_cast&lt;CStatic*&gt;(arg); Sleep(3000); pStaticText-&gt;SendMessage(WM_SETTEXT, 0, (LPARAM)L"text"); return 0; } </code></pre> <p>Option 2 - pass an handle :</p> <pre><code>TestDialog dlg1; ::_beginthreadex(NULL, 0, &amp;tSetTextByHandle, &amp;(dlg1.m_StaticText.m_hWnd), 0, NULL); dlg1.DoModal(); UINT WINAPI tSetTextByHandle(LPVOID arg) { HWND * pTextHandle = static_cast&lt;HWND*&gt;(arg); Sleep(3000); ::SendMessage(*pTextHandle, WM_SETTEXT, 0, (LPARAM)L"text"); return 0; } </code></pre> <p>Should I really prefer using handles when accessing controls by multiple threads? Or is it enough to rely on SendMessage() to cover the thread-safety matter when accessing the control?</p>