detect event in MFC dialog
-
Windows 7, Visual Studio 2008, MFC, C++ A thread is started when a dialog button is clicked. The thread performs some tasks than sets event 100, an arbitrary number for conversation. The dialog is to detect that event and display some text without user intervention. What can be done in the dialog to accomplish this?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Windows 7, Visual Studio 2008, MFC, C++ A thread is started when a dialog button is clicked. The thread performs some tasks than sets event 100, an arbitrary number for conversation. The dialog is to detect that event and display some text without user intervention. What can be done in the dialog to accomplish this?
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
It would be a better idea to use the proper Windows mechanisms. When the thread has completed its task it should send a message to the dialog.
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
Hi,
bkelly13 wrote:
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events.
Threads can have a messages queue on Microsoft Windows. How to post a thread message to a console application.[^] Using PostThreadMessage function[^] would be a great way to solve your issue. Potentially without creating additional threads. Best Wishes, -David Delaune
-
Hi,
bkelly13 wrote:
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events.
Threads can have a messages queue on Microsoft Windows. How to post a thread message to a console application.[^] Using PostThreadMessage function[^] would be a great way to solve your issue. Potentially without creating additional threads. Best Wishes, -David Delaune
-
Hi,
bkelly13 wrote:
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events.
Threads can have a messages queue on Microsoft Windows. How to post a thread message to a console application.[^] Using PostThreadMessage function[^] would be a great way to solve your issue. Potentially without creating additional threads. Best Wishes, -David Delaune
That looks useful. My TCP app can post messages to a dialog so the user can determine the state of the thread. One dialog might display the status of several instances of the message app. I will have to figure out how the app will get the ID to that dialog, but it may well be useful. Thank you for the tip.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
Valid point. But this thread is will operate in an environment with no window and will set several events multiple times before exiting. No messages, only events. MFC and the dialog are being used as a test vehicle to get close to the thread during development. Maybe I should switch to a console environment now. Or continue on a use a button to poll for events then update the status as appropriate.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
Messaging is likely the best alternative (although not the only option). It is also common for people to make invisible windows simply for the messaging mechanism (instead of handling it by hand as in the article below). Your other alternative could be to have the window occasionally check a critical section (or mutex) protected variable to know the current state.
-
Messaging is likely the best alternative (although not the only option). It is also common for people to make invisible windows simply for the messaging mechanism (instead of handling it by hand as in the article below). Your other alternative could be to have the window occasionally check a critical section (or mutex) protected variable to know the current state.
This MFC dialog is just a test vehicle to develop the classes and thread that will perform all the TCP/IP I/O. I will add a button to poll the events set by the TCP code, or maybe a button that starts a timer that leads to a poll every couple of seconds. Thanks for taking the time to reply.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
-
This MFC dialog is just a test vehicle to develop the classes and thread that will perform all the TCP/IP I/O. I will add a button to poll the events set by the TCP code, or maybe a button that starts a timer that leads to a poll every couple of seconds. Thanks for taking the time to reply.
Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com
I use the polling method for high-frequency updates to a GUI. Since messaging can lead to a flood of messages updating things at such a high-rate you probably wouldn't make out the least significant digits.