|
-
February 8th, 2006, 05:30 AM
#1
CriticalSection DeadLock ?...
Hi to all
I am using CriticalSections in a MFC based application
I have a dialog, containing a CListCtrl. I use a thread to fill the list because it contains 5000 elements and I don't want to block my dialog when I fill it.
I pass a pointer to my dialog object to the thread.
in the thread I use criticalsection to limit access to the listCtrl,
and in my dialog I limit access to the listctrl by the same criticalsection.
sometimes I get deadlocks??
What happens when a thread access the listCtrl to fill it, and the user clic on it???
Code:
CMyListCtrl::Onclick()
{
EnterCriticalSection(m_pSection);
////Do something with the list
LeaveCtriticalSection(m_pSection);
}
MyThread(LPVOID lParam)
{
CMyDialog *pDlg = (CMyDialog*)lParam;
if(pDlg)
{
EnterCriticalSection(pDlg->m_pSection);
/////Do something with the m_pDlg->m_listCtrl takes 1-2 secondes
/// TAG 1
LeaveCriticalSection(pDlg->m_pSection);
}
}
When the Thread is at TAG 1, and I clic on the list I get the deadlock?
any Idea?
Thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|