EXECUTE code 1 after the other only
-
Hello Friends, I have the following lines of code. The CRHPostMessageToParent() calls parent to parent class methods.
AfxMessageBox(\_T("Page2::Inside TellPArent")); // Update deptStock obj with the parent this->CRHPostMessageToParent(WM\_CHANGED\_DS, (int)&deptStock); this->ShowWindow(SW\_HIDE); this->CRHPostMessageToParent(WM\_SHOW\_NEXT\_VIEW, i); AfxMessageBox(\_T("Page2::Finished TellParent"));
These codes start running untill the previous line code is not completed. I want to ensure, that it should proceed to next line only when the first is completed. The CRHPostMessageToParent() calls PostMessage () to parent & returns void. The parent function OnChanged_DS() returns LRESULT. In Java, this can be achived by assigning each task in thread and synchronizing it, which makes sure that the process is completed & then only the handle is released. How do I achive the same in VC++6? I hope I have explained my situation to the best. If yet not, ask me.
Thanks Terry
-
Hello Friends, I have the following lines of code. The CRHPostMessageToParent() calls parent to parent class methods.
AfxMessageBox(\_T("Page2::Inside TellPArent")); // Update deptStock obj with the parent this->CRHPostMessageToParent(WM\_CHANGED\_DS, (int)&deptStock); this->ShowWindow(SW\_HIDE); this->CRHPostMessageToParent(WM\_SHOW\_NEXT\_VIEW, i); AfxMessageBox(\_T("Page2::Finished TellParent"));
These codes start running untill the previous line code is not completed. I want to ensure, that it should proceed to next line only when the first is completed. The CRHPostMessageToParent() calls PostMessage () to parent & returns void. The parent function OnChanged_DS() returns LRESULT. In Java, this can be achived by assigning each task in thread and synchronizing it, which makes sure that the process is completed & then only the handle is released. How do I achive the same in VC++6? I hope I have explained my situation to the best. If yet not, ask me.
Thanks Terry
Trupti Mehta wrote:
How do I achive the same in VC++6?
You can also use synchronization.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Hello Friends, I have the following lines of code. The CRHPostMessageToParent() calls parent to parent class methods.
AfxMessageBox(\_T("Page2::Inside TellPArent")); // Update deptStock obj with the parent this->CRHPostMessageToParent(WM\_CHANGED\_DS, (int)&deptStock); this->ShowWindow(SW\_HIDE); this->CRHPostMessageToParent(WM\_SHOW\_NEXT\_VIEW, i); AfxMessageBox(\_T("Page2::Finished TellParent"));
These codes start running untill the previous line code is not completed. I want to ensure, that it should proceed to next line only when the first is completed. The CRHPostMessageToParent() calls PostMessage () to parent & returns void. The parent function OnChanged_DS() returns LRESULT. In Java, this can be achived by assigning each task in thread and synchronizing it, which makes sure that the process is completed & then only the handle is released. How do I achive the same in VC++6? I hope I have explained my situation to the best. If yet not, ask me.
Thanks Terry
You can use MFC sync classes like CMutex,CEvent and CSemaPhore.
Sudhir Kumar
-
Hello Friends, I have the following lines of code. The CRHPostMessageToParent() calls parent to parent class methods.
AfxMessageBox(\_T("Page2::Inside TellPArent")); // Update deptStock obj with the parent this->CRHPostMessageToParent(WM\_CHANGED\_DS, (int)&deptStock); this->ShowWindow(SW\_HIDE); this->CRHPostMessageToParent(WM\_SHOW\_NEXT\_VIEW, i); AfxMessageBox(\_T("Page2::Finished TellParent"));
These codes start running untill the previous line code is not completed. I want to ensure, that it should proceed to next line only when the first is completed. The CRHPostMessageToParent() calls PostMessage () to parent & returns void. The parent function OnChanged_DS() returns LRESULT. In Java, this can be achived by assigning each task in thread and synchronizing it, which makes sure that the process is completed & then only the handle is released. How do I achive the same in VC++6? I hope I have explained my situation to the best. If yet not, ask me.
Thanks Terry
-
Does your CRHPostMessageToParent call PostMessage or SendMessage? Using SendMessage means that control does not return until the message has been processed which sounds like what you want. Judy
JudyL_FL wrote:
Does your CRHPostMessageToParent call PostMessage or SendMessage?
Did you miss: The CRHPostMessageToParent() calls PostMessage ()...
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
JudyL_FL wrote:
Does your CRHPostMessageToParent call PostMessage or SendMessage?
Did you miss: The CRHPostMessageToParent() calls PostMessage ()...
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
DavidCrow wrote:
Did you miss
Yes and no :) . Yes, in that I didn't see the exact API function name and read the function description as "post a message." No, in that the function name implies Post instead of Send. More important was to make sure the OP was aware of the difference between PostMessage and SendMessage - unclear from the original post. Judy
-
DavidCrow wrote:
Did you miss
Yes and no :) . Yes, in that I didn't see the exact API function name and read the function description as "post a message." No, in that the function name implies Post instead of Send. More important was to make sure the OP was aware of the difference between PostMessage and SendMessage - unclear from the original post. Judy
It calls the PostMessage(message, WPARAM, LPARAM) How do I achieve the goal? Can you give some guidance/example to work with CEvent etc classes as mentioned in ealier post.
Thanks Terry
-
It calls the PostMessage(message, WPARAM, LPARAM) How do I achieve the goal? Can you give some guidance/example to work with CEvent etc classes as mentioned in ealier post.
Thanks Terry
-
I'm not the one who mentioned using CEvent. My suggestion was to call SendMessage instead of PostMessage to make the caller wait until the message was processed. Judy
Oh sorry Judy. must have read in some website for solution of the problem. Anyways, I changed from PostMessage to SendMessage. Was just wondering will it make any differnece in using any of those. I mean, i changed from post to send will that make any other impact on the application other than not returning till the message is posted. Am just curious about it. Thanks Judy.
Thanks Terry
-
Oh sorry Judy. must have read in some website for solution of the problem. Anyways, I changed from PostMessage to SendMessage. Was just wondering will it make any differnece in using any of those. I mean, i changed from post to send will that make any other impact on the application other than not returning till the message is posted. Am just curious about it. Thanks Judy.
Thanks Terry
Trupti Mehta wrote:
Was just wondering will it make any differnece in using any of those. I mean, i changed from post to send will that make any other impact on the application other than not returning till the message is posted.
Nope, that is the only difference. It can become an issue in multi-threaded programs whether you use Post or Send depending on how your GUI thread and your worker threads synchronize with each other. If you use Send, you need to be (even more) careful about potential deadlocks since Send causes your thread to wait. Judy