I have clist control in my CListView based class. I also defined a function AddMsg to add item to the clist control. This function will be called from many places (threads) in the problem. I wan to have a threadsafe access to the control. I tried to use CCriticalSection for it, but the program will lock up, I think some deadlock is happening. How can I solve it.


CCriticalSection m_CriticalSection;

void CMyView::AddMsg(CString &msg)
{
m_CriticalSection.Lock();

do list control access...
m_CriticalSection.Unlock();
}