WinAPI & threading

This is a discussion on WinAPI & threading within the Windows Programming forums, part of the Platform Specific Boards category; I used MessageBox only for debug purposes, and to exhibit the absolute madness that is wreaking havoc on my thread. ...

  1. #16
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    I used MessageBox only for debug purposes, and to exhibit the absolute madness that is wreaking havoc on my thread.
    I'm not sure what I would use PostThreadMessage for as all messages are sent one way, from the Thread func to the UI thread, in which case, isn't SendMessage just as good then?

  2. #17
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    SendMessage needs a window handle as the target and blocks. PostThreadMessage needs a thread ID or handle and returns immediately.
    Since you're always sending to the UI thread, the blocking is the more important difference.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  3. #18
    Registered Abuser
    Join Date
    Jun 2006
    Location
    Toronto
    Posts
    591
    Which is why I wasn't quite sure why I would use PostThreadMessage here, since SendMessage is clearly the desired behaviour in this case. Nevertheless though, I am in the process of re-writing the thread, this time I will do only bare-bones calculations in the thread and pass a list of processed info back to the caller so that it can be used to update the UI. My initial intent was for the UI updating to be a part of the thread itself so that updating would not block/eat up time from the window function, but hopefully this time will be negligible, we'll see.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem threading a member function
    By Syneris in forum C++ Programming
    Replies: 10
    Last Post: 12-31-2008, 06:26 PM
  2. c++ threading
    By Anddos in forum C++ Programming
    Replies: 4
    Last Post: 12-28-2005, 02:29 PM
  3. Problem with threading
    By osal in forum Windows Programming
    Replies: 6
    Last Post: 07-21-2004, 12:41 PM
  4. do i still need winAPI
    By datainjector in forum Windows Programming
    Replies: 8
    Last Post: 07-12-2003, 01:43 AM
  5. references for the winapi
    By stallion in forum Windows Programming
    Replies: 9
    Last Post: 01-28-2003, 01:56 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21