Home > Software engineering >  MFC window, created in the child thread blocking when the main framework, why the threads window has
MFC window, created in the child thread blocking when the main framework, why the threads window has

Time:09-18

MFC single document application, use Afxbeginthread (cwinthread *,) to create a UI thread, the thread is created inside a window, now main frame block in the drawing function, the thread in the window will be blocked at this time, please? If you are blocked, why? How do the main framework block in the drawing not blocking a response message window?

CodePudding user response:

Block of main frame, if is infinite loop, must kill the process,

CodePudding user response:

reference 1st floor schlafenhamster response:
main frame block, if it is a dead loop, must kill the process,

What do you mean? In fact, I just want to, main frame block, the window of the thread is not blocked

CodePudding user response:

Unless you AttachThreadInput or SetParent/SetOwner two interface thread should not block each other,

CodePudding user response:

The
reference 3 floor Jiang Sheng response:
unless you AttachThreadInput or SetParent/SetOwner two interface thread should not block each other,

Main frame death cycle, another thread does not block the window?

CodePudding user response:

Create a window in the child thread, message loop in a child thread, he has its own cycle, and the main thread irrelevant, not blocked,

CodePudding user response:

Haven't met in the thread created window, can change to let the main dialog to create?

CodePudding user response:

refer to 6th floor kyosuke kanou 1989 response:
didn't met thread created window, can change to let the main dialog to create?

Is because the main thread in the busy, just open another thread created the window

CodePudding user response:

refer to 6th floor kyosuke kanou 1989 response:
didn't met thread created window, can change to let the main dialog to create?

Void CDLG: : onbnclickbutton1 ()
{
_begindthread (threadfun, 0, 0);
while(1);
}
Void threadfun (void * argu)
{
Cwinthread * pthread=_afxbeginthread (runtime_class (cmythread));
Pthread - & gt; Postthreadmessage (wm_test, 0, 0);
while(1);
}

Void cmythread: : ontest (... )
{
If (ptest!=null)
{
Ptest=new cdlgtest;
Ptest - & gt; Create (... );
Ptest - & gt; Showwindow (... );
}
}

CodePudding user response:

The
reference 5 floor smwhotjay response:
create a window in the child thread, message loop in a child thread, he has its own cycle, nothing to do with the main thread, not blocked,

I write simple code below, could you help me to look at, code idea is wrong?

CodePudding user response:

IE6 is multiple main frame, each main frame in different threads, block of no effect,

In a separate thread between Windows have the parent-child relationships, there is a problem, because erasing what will wait for each other, different threads window to independence,

CodePudding user response:

Your own interface thread has its own message loop, how can block each other? Won't! Unless you have a problem logic written

CodePudding user response:

The child thread does not block
But not so operation Suggestions
Should try to avoid the main thread blocking

CodePudding user response:

11 references hurryboylqs response:
your own interface thread has its own message loop, how can block each other? Won't! Unless you have a problem logic written

Logic, 8/f code wow,,,,,,,

CodePudding user response:

references to the tenth floor Jiang Sheng response:
IE6 is multiple main frame, each main frame in different threads, block of no effect,

In a separate thread between Windows have the parent-child relationships, there is a problem, because erasing what will wait for each other, different threads window to independence,

Such as the code on the 8th floor, you see if there are any problems

CodePudding user response:

Key code of the specified parent window, you gave a ellipses... How do I know if you have any questions,

CodePudding user response:

Pthread - & gt; Postthreadmessage (wm_test, 0, 0);
the while (1); ??

While (1) Sleep (100);

CodePudding user response:

GUI in the child thread ever used when beginners MFC, but unfortunately not enough level, is always a problem, have been using PostThreadMessage later, PostMessage to interact

CodePudding user response:

Will be a little effect, but can be roughly run normally,
Because of some news distribution, is a child window if not running, will run to the parent window,
  • Related