?
Solved

<=== >  Message Pump  <===>

Posted on 1998-07-02
4
Medium Priority
?
680 Views
Last Modified: 2013-11-19
if a worker thread is derived from CWinThread using AfxBeginThread why does it not have a message pump ???
0
Comment
Question by:pcj0961
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1318664
There are tow kind of of thread, UI thread and worker thread. UI thread contains message pump and in MFC usually derived from CWinThread. Worker thread is usually thread function so when this function returns worker thread terminates. Thre are two overloaded version of AfxBeginThread. When you create UI thread you cpesify pointer to CWinThread class. This class has Run virtual function that contains message pump. The second version of AfxBeinThread is passed pointer to worker thread entry function.
0
 
LVL 1

Author Comment

by:pcj0961
ID: 1318665
I have created a worker thread using AfxBeginThread
that has a for(;;){} loop that never returns (it runs continuosly looking for messages passed to it). Is it better
to do this type of application (thread) with a UI thread and use the Run(){} loop of the CWinThread object to do my processing.
0
 
LVL 7

Expert Comment

by:galkin
ID: 1318666
Worker thread doesn't have any windows so it is impossible to send message to it. Usually worker thread does some data processing and notifies main UI thread using messages. If you still want your worker thread to have a window, create hidden window inside CWinThread::InitInstance and assign it's pointer to m_pMainWnd. then you can send messages to this hidden window.
0
 
LVL 4

Expert Comment

by:piano_boxer
ID: 1318667
Any thread can have a message pump! But if the thread do not create any windows or do not need to receive messages posted using PostThreadMessage() there is no reason to do a message pump.

Remember: Windows are owned by the thread that created them.


0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question