Home > Software engineering >  MFC multithreading, run in the same window display
MFC multithreading, run in the same window display

Time:10-04

For MFC is not very understanding, because big job need to contact the MFC programming interface, and involve multithreading issues, hope to have Daniel can explain more, many thanks!
I want to realize the function of the is:
1. The use of OPENCV, through camera to real-time people gesture recognition, including stone, scissors and paper three gestures (single gesture recognition tracking procedure no problem), among them, the main executive body gesture recognition procedure is a while loop, roughly as follows:
 while (capture)//the capture to get the camera signal, here for real-time tracking calculation 
{
Gestures to detect recognition...
}

This program is exclusive of CPU, as long as the start will continue in the while loop execution;
2. The use of random function, randomly generated 1, 2, 3, one of the three Numbers to represent computer mora results; And gesture recognition program does not have any data interaction;

Because of gesture recognition program has an exclusive feature, in the process of cycle test can't be other unrelated calculation, so I took into account the multithreading, simply use under Windows before handle and CreateThread function, but under the MFC use worker threads or when the user thread (tried), are encountered after starting gesture recognition threads to other operating problems, I want to ask isn't multithreaded MFC window in the true sense of multithreading? (I've seen some people say that the MFC window is single-threaded, sweat ~ ~),
I also thought of many other ways to detect interrupt gestures, such as in computer punch thread postmessage a signal to the gesture recognition threads, but met start gesture recognition thread cannot perform computer punch thread; Also considered additional set a gesture recognition window, and set a on_clicked_button trigger to cancel gesture recognition thread and the window, but after trying don't interrupt while (capture), good tenacity T.T, feeling I like is not really a multithreading, or a single thread sequentially,
Saw cbNotes the large post, benefits, but described in the user thread, copying files actually is also a single task thread, involves copying files, only new window displaying the progress of copying files is updated, so doubt whether really is multithreaded, MFC cbNotes big post address: http://blog.csdn.net/cbnotes/article/details/8465212
Anyone can greatly help me to solve it? Or put forward some new solutions, not very grateful!

CodePudding user response:

Multiple Threads in the User Interface of http://msdn.microsoft.com/zh-cn/library/ms810439.aspx

CodePudding user response:

Don't you go to not go to find information online search, started Posting to doubt the things they don't know is it ok, who do you think will answer your question?

CodePudding user response:

Thread proper Sleep in a while loop to yield the CPU to other threads

CodePudding user response:

reference 1/f, zhao teacher reply:
Multiple Threads in the User Interface of http://msdn.microsoft.com/zh-cn/library/ms810439.aspx
this is the last century is too old

CodePudding user response:

1. First of all, don't in the main thread (that is, the UI thread) do cpu-intensive computing, otherwise your program must be stuck! BuKa, bill back thanks to you for the teacher,
2. Need to understand the difference between a worker thread and the UI thread, and how to update the UI thread, worker thread otherwise your application or stuck, or crash,
3. The importance of the algorithm, the cpu-intensive calculation, algorithm is very important, a good algorithm and the algorithm of differential sometimes 100% difference,

Of course, this is all theory suggestion, and you didn't give specific code, the za it is impossible to give specific advice,

CodePudding user response:

reference 4 floor xinkexue response:
Quote: reference, 1/f, zhao teacher reply:
Multiple Threads in the User Interface http://msdn.microsoft.com/zh-cn/library/ms810439.aspx
this is the last century is too old

The older, the wiser

CodePudding user response:

Open is the thread, and do arithmetic, and then use the message function for manipulating UI interface display updates
  • Related