Hi All,
I met a problem when access WinRT object in the thread which created by Win32 API:CreateThread().
I store the WinRT object as a class member and to access it by another thread.
But it will cause crash issue when I try access any member variable or method of the WinRT object.
Is it the limitation of WinRT object? Or Did I do anything wrong?
Below is the code piece I wrote:
HRESULT UpdateThread::Start(WriteableBitmap^ target_bitmap)
{
m_bitmap = target_bitmap);
m_thread_handle = CreateThread(NULL,
0,
ThreadProc,
(LPVOID)this,
0,
&m_threadId);
return S_OK;
}
DWORD WINAPI UpdateThread::ThreadProc(LPVOID pParam)
{
UpdateThread* p_this = (UpdateThread *)pParam;
while (!p_this->m_stop)
{
p_this->m_bitmap->Invalidate(); // crash there!
Sleep(1);
}
return 0;
}