Thread: WinAPI & threading

  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,895
    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.

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, 07:26 PM
  2. c++ threading
    By Anddos in forum C++ Programming
    Replies: 4
    Last Post: 12-28-2005, 03: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, 02:56 AM