home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / os2 / programm / 7284 < prev    next >
Encoding:
Internet Message Format  |  1993-01-03  |  4.0 KB

  1. Path: sparky!uunet!usc!news.service.uci.edu!orion.oac.uci.edu!lhoang
  2. From: lhoang@orion.oac.uci.edu (Long Hoang)
  3. Subject: Re: Dialogs + Threads = Problems. Help!
  4. Nntp-Posting-Host: orion.oac.uci.edu
  5. Message-ID: <2B47581B.10791@news.service.uci.edu>
  6. Newsgroups: comp.os.os2.programmer
  7. Organization: University of California, Irvine
  8. Lines: 79
  9. Date: 3 Jan 93 21:18:19 GMT
  10. References: <92366.110046U37127@uicvm.uic.edu> <1993Jan3.054918.1861@netcom.com>
  11.  
  12. In article <1993Jan3.054918.1861@netcom.com> daveb@netcom.com (Dave Briccetti) writes:
  13. >U37127@uicvm.uic.edu () writes:
  14. >: I have received E-mail (rob@cc.gatech.edu) saying that the thread
  15. >: issuing the WinSendMsg must have a msg Q as well; I also received
  16.           Yes.
  17. >: another answer saying that a thread *cannot* use WinSendMsg
  18. >: to a window belonging to another thread (lhoang@orion.uci.edu) and
  19. >: that this behaviour is documented.  Apparently IBM recommends
  20.  
  21.           After I received E-mail reply from you, I have been trying to 
  22.           find where I read this from the OS/2 2.0 Tech Lib - Programming 
  23.           Guide Volume's, with no sucess.  I remember reading something like 
  24.           "to send message to another thread, use WinPostMsg() ...",
  25.           while I was writing a progress bar for the program upload/download
  26.           ARTs from IBM mainframe to PC. I did not read PM Programming 
  27.           Reference Vol 1 to point out the real difference
  28.           between the implementations of the two. (Chapter 2. Messages and
  29.           Message Queues - Programming Guide Vol 2, OS/2 Tech Lib, also
  30.           discusses about the messages structures in PM environment.)
  31.  
  32.           I apologize for what you have been going through because of my 
  33.           incorrect answer.
  34.  
  35. >: WinPostMsg.  Perhaps to maintain serialization via the msg Q
  36.  
  37.           "The WinPostMsg function creates a QMSG struture for the message
  38.            and copies the message to the message queue corresponding to the 
  39.            given window.
  40.            The application's message loop eventually retrieves the message
  41.            and dispatches it to the appropriate window procedure."
  42.  
  43. >: as opposed to WinSendMsg which is a direct call to the function?
  44.  
  45.           "The WinSendMsg function passes the message to the window
  46.            procedure corresponding to the given window. 
  47.            The function waits until the window procedure completes 
  48.            processing and then returns the message results."
  49.  
  50.      Other quotes:
  51.           "If the window receiving the message belongs
  52.            to the same thread, the window function is called 
  53.            immediately as a subroutine. If the window is
  54.            of another thread or process, the operating system 
  55.            switches to the appropriate thread that enters
  56.            the necessary window procedure recursively.
  57.            The message is not placed in the queue of the
  58.            destination thread."
  59.  
  60.           "Any thread in the application can post a message to a
  61.            message queue, even if the thread has no message queue of its own.
  62.            However, only thread that has a message queue can send a message.
  63.            Sending a message between threads is relatively uncommon. For one
  64.            reason, sending a message is costly in terms of system performance."
  65.  
  66.       Your guess is right on the money.
  67. >: 
  68. >: Is there a definitve doc anywhere on this subject?  My interim kludge has been
  69. >: to use WinPostMsg, with an app defined msg, and block until the receiver
  70.         or to create a message queue and use WinSendMsg, if coding blocking
  71.         becomes tedious.
  72. >: processes the msg and shoves the result into a shared data structure.
  73. >
  74. >The notes in the PM Reference make it quite clear that WinSendMsg to a
  75. >window belonging to another thread IS allowed.  The message is sent 
  76. >synchronously and the thread switching is automatic.
  77.    Yes.
  78. >
  79. >I've done it myself for years.
  80.    Beginner in OS2 PM programming. I'll try to keep my mouth shut and do my
  81.   homework better.
  82. >
  83. >-- 
  84. >
  85. >Dave Briccetti, Owner, Dave Briccetti & Associates
  86. >OS/2 Developer/Consultant
  87. >P.O. Box 1713
  88. >Lafayette, CA  94549-7013
  89.  
  90. Long Hoang.
  91.