Home > Software engineering >  TreeCtrl GetItemData (), need to use message loop?
TreeCtrl GetItemData (), need to use message loop?

Time:09-16

Today in the child thread tree control operation, in the call GetItemData (), found that the code can't stuck


The main thread:
.

AfxBeginThread (f_fun_Thread,);
Sleep (30000);

The child thread:
F_fun_Thread {
M_tree - & gt; GetItemData (hItem); --> Jam, such as the main thread Sleep (30000); Until after running down
}

Then do forward in the main thread, the child thread would have a normal
AfxBeginThread (f_fun_Thread,);
Int count=0;
While (count++ & lt; 60) {
While (: : PeekMessage (& amp; MSG, NULL, 0, 0, PM_REMOVE)) {
: : TranslateMessage (& amp; MSG);
: : DispatchMessage (& amp; MSG);
}
Sleep (500);
}

So the message loop GetItemData need???????

CodePudding user response:

In the main thread m_tree?
Sleep (30000); The main thread is not running!

CodePudding user response:

reference 1st floor schlafenhamster response:
m_tree in the main thread?
Sleep (30000); The main thread is not running!

M_tree is in the main thread of the new, already inside the pointer to the child thread,
In the main thread during sleep, the child thread cannot operate m_tree?
  • Related