Article View: comp.os.os2.programmer
Article #2759Re: Dialogs + Threads = Problems. Help!
From: Long Hoang
Date: Sun, 03 Jan 1993 21:18
Date: Sun, 03 Jan 1993 21:18
79 lines
4237 bytes
4237 bytes
In article <1993Jan3.054918.1861@netcom.com> daveb@netcom.com (Dave Briccetti) writes:
>U37127@uicvm.uic.edu () writes:
>: I have received E-mail (rob@cc.gatech.edu) saying that the thread
>: issuing the WinSendMsg must have a msg Q as well; I also received
Yes.
>: another answer saying that a thread *cannot* use WinSendMsg
>: to a window belonging to another thread (lhoang@orion.uci.edu) and
>: that this behaviour is documented. Apparently IBM recommends
After I received E-mail reply from you, I have been trying to
find where I read this from the OS/2 2.0 Tech Lib - Programming
Guide Volume's, with no sucess. I remember reading something like
"to send message to another thread, use WinPostMsg() ...",
while I was writing a progress bar for the program upload/download
ARTs from IBM mainframe to PC. I did not read PM Programming
Reference Vol 1 to point out the real difference
between the implementations of the two. (Chapter 2. Messages and
Message Queues - Programming Guide Vol 2, OS/2 Tech Lib, also
discusses about the messages structures in PM environment.)
I apologize for what you have been going through because of my
incorrect answer.
>: WinPostMsg. Perhaps to maintain serialization via the msg Q
"The WinPostMsg function creates a QMSG struture for the message
and copies the message to the message queue corresponding to the
given window.
The application's message loop eventually retrieves the message
and dispatches it to the appropriate window procedure."
>: as opposed to WinSendMsg which is a direct call to the function?
"The WinSendMsg function passes the message to the window
procedure corresponding to the given window.
The function waits until the window procedure completes
processing and then returns the message results."
Other quotes:
"If the window receiving the message belongs
to the same thread, the window function is called
immediately as a subroutine. If the window is
of another thread or process, the operating system
switches to the appropriate thread that enters
the necessary window procedure recursively.
The message is not placed in the queue of the
destination thread."
"Any thread in the application can post a message to a
message queue, even if the thread has no message queue of its own.
However, only thread that has a message queue can send a message.
Sending a message between threads is relatively uncommon. For one
reason, sending a message is costly in terms of system performance."
Your guess is right on the money.
>:
>: Is there a definitve doc anywhere on this subject? My interim kludge has been
>: to use WinPostMsg, with an app defined msg, and block until the receiver
or to create a message queue and use WinSendMsg, if coding blocking
becomes tedious.
>: processes the msg and shoves the result into a shared data structure.
>
>The notes in the PM Reference make it quite clear that WinSendMsg to a
>window belonging to another thread IS allowed. The message is sent
>synchronously and the thread switching is automatic.
Yes.
>
>I've done it myself for years.
Beginner in OS2 PM programming. I'll try to keep my mouth shut and do my
homework better.
>
>--
>
>Dave Briccetti, Owner, Dave Briccetti & Associates
>OS/2 Developer/Consultant
>P.O. Box 1713
>Lafayette, CA 94549-7013
Long Hoang.
Technical Details
Message-ID:
<2B47581B.10791@news.service.uci.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!usc!news.service.uci.edu!orion.oac.uci.edu!lhoangReferences:
<92366.110046U37127@uicvm.uic.edu> <1993Jan3.054918.1861@netcom.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!usc!news.service.uci.edu!orion.oac.uci.edu!lhoang From: lhoang@orion.oac.uci.edu (Long Hoang) Subject: Re: Dialogs + Threads = Problems. Help! Nntp-Posting-Host: orion.oac.uci.edu Message-ID: <2B47581B.10791@news.service.uci.edu> Newsgroups: comp.os.os2.programmer Organization: University of California, Irvine Lines: 79 Date: 3 Jan 93 21:18:19 GMT References: <92366.110046U37127@uicvm.uic.edu> <1993Jan3.054918.1861@netcom.com>