ATL-COM Thread problems

Hello.

I hava a ATL COM application created in visual c++ 2005.
This application has an atl simple object that only does this:

The FinalConstruct function creates one thread, somethig like:
HRESULT FinalConstruct()
{
DWORD threadId;
m_ThreadUp = 1;
m_handle = CreateThread(NULL, 0, MyRoutine, NULL, 0, &threadId );
return S_OK;
}

FinalRelease method is like this:
void FinalRelease()
{
m_ThreadUp--;
WaitForSingleObject(m_handle, INFINITE);
CloseHandle(m_handle);
}

The Thread Proc looks like this:
DWORD WINAPI MyRoutine(LPVOID param )
{
CoInitializeEx(NULL,COINIT_MULTITHREADED);
while (m_ThreadUp)
Sleep(100) ;
CoUninitialize();
}

Thread starts ok.
The problem is the function WaitForSingleObject in the FinalRelease method.
Application simply exits, no error messages, exit codes, nothing when tries to execute the function.
In the debugger if i press F10 over WaitForSingleObject the application exits, CloseHandle neves executes.
I thinks that could be something about atl-com threading that i'm passing by.
Someone can help me?

Thank in advance
[1264 byte] By [AlexDR] at [2007-11-19 19:41:56]