Mechi
2010-05-03 13:16:41 UTC
Hi!
I create and call 2 threads (camera and Display) and each thread has
an DeadEvent which is set when the thread exits. This adds 4 new
Handles.
I'm using ProcessExplorer to monitor the handles in my application.
Every time the threads are opened and then closed, there is still one
handle that is not closed down - a leak. I traced that handle to the
WaitForSingleObject on the DeadEvent of the first thread. Has anyone
experienced this?
Any ideas? Code below...
Thanks,
Mechi
To be more specific:
// creating the threads - 4 new handles
if (!m_hCameraDead) m_hCameraDead = CreateEvent(NULL, TRUE, FALSE,
NULL);
if (!hCameraThread)
hCameraThread = (HANDLE)_beginthreadex(NULL,0,Camera_Thread,
this, 0, 0);
if (!m_hDisplayDead) m_hDisplayDead = CreateEvent(NULL, TRUE, FALSE,
NULL);
if (!hDisplayThread)
hDisplayThread = (HANDLE)_beginthreadex(NULL, 0,Display_Thread,
this, 0, 0);
// checking to see that the CameraThread didn't exit right away - adds
an extra handle
if (WaitForSingleObject(m_hCameraDead, 3) != WAIT_TIMEOUT)
{
CloseHandleEx(&hCameraThread);
}
I create and call 2 threads (camera and Display) and each thread has
an DeadEvent which is set when the thread exits. This adds 4 new
Handles.
I'm using ProcessExplorer to monitor the handles in my application.
Every time the threads are opened and then closed, there is still one
handle that is not closed down - a leak. I traced that handle to the
WaitForSingleObject on the DeadEvent of the first thread. Has anyone
experienced this?
Any ideas? Code below...
Thanks,
Mechi
To be more specific:
// creating the threads - 4 new handles
if (!m_hCameraDead) m_hCameraDead = CreateEvent(NULL, TRUE, FALSE,
NULL);
if (!hCameraThread)
hCameraThread = (HANDLE)_beginthreadex(NULL,0,Camera_Thread,
this, 0, 0);
if (!m_hDisplayDead) m_hDisplayDead = CreateEvent(NULL, TRUE, FALSE,
NULL);
if (!hDisplayThread)
hDisplayThread = (HANDLE)_beginthreadex(NULL, 0,Display_Thread,
this, 0, 0);
// checking to see that the CameraThread didn't exit right away - adds
an extra handle
if (WaitForSingleObject(m_hCameraDead, 3) != WAIT_TIMEOUT)
{
CloseHandleEx(&hCameraThread);
}