Subj : Re: threading problem in dll??? Help needed badly. To : comp.programming.threads From : chuayongquan Date : Thu Jul 07 2005 07:44 pm Paul Pluzhnikov wrote: > chuayongquan@hotmail.com writes: > > > UINT abc::abcfunction(LPVOID pParam) > > { > > > > abc* pCM = (abc*)pParam; > > > > ::CoInitialize(NULL); > > > > while (1) { > > TryEnterCriticalSection(CS); [1] > > What happens if the CS is already owned by another thread at point [1] above? > The TryEnterCriticalSection() will fail, but you proceed as if > it didn't. Subsequent calls to LeaveCriticalSection() will cause > all manner of corruption. > > > // my thread code here > > if (stopthread){ > > LeaveCriticalSection(CS); > > break; > > } > > LeaveCriticalSection(CS); > > } > > ::CoUninitialize(); > > return 0; > > } > > > > //end thread function > > Cheers, > -- > In order to understand recursion you must first understand recursion. > Remove /-nsp/ for email. Then do you have a solution for this. i have been searching for the answer for weeks... Thx .