Thread: constant code

  1. #1

    constant code

    this is most likely a very stupid question but i am a beginer to win32 api, where would you write code so that it is constantly being active because writing it in WndProc it only works when a message is sent (non constant)?

  2. #2
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Acting on the receipt of a message is the core design rationale of Windows. Your WinMain function is always active, it is, however in a tight loop Getting message, Translating messages and Dispatching message. If you want to do something simple, you could do it in this loop, but I would strongly advise you not to as the performance of your application will be drastically affected.

    If, as I suspect, you want to have your task doing something, at the same time as servicing your messages, you need to create a "worker thread". Look up the _beginthread() API function in the help. Don't use CreateThread().
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Explain this C code in english
    By soadlink in forum C Programming
    Replies: 16
    Last Post: 08-31-2006, 12:48 AM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  3. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  4. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM
  5. Replies: 4
    Last Post: 01-16-2002, 12:04 AM