Thread: Simultaneous Tasks

  1. #1
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853

    Simultaneous Tasks

    I am wondering what are my options when I want to do to jobs "simultaneously". In more words I would like for example (on a window):
    -Every x seconds a square moves forward
    -If you press a button a square stops

    What is the way to go? I can think of a lot of ways to do it in a more "simple" language (like C) but I am more interested in actual code and functions. Like doing the job simple and efficiently

    Merci beacoup (sp? its been years...)

  2. #2
    Webhead Spidey's Avatar
    Join Date
    Jul 2009
    Posts
    285
    "simultaneously"
    I'm not sure what you mean by that, do you want to use separate threads ?

    The ball moving is simple logic flow example,

    Code:
    while(true)
    {
       if(canMove)
          ballPos += ballVel * dt;
       if(buttonPressed)
         canMove = false;
    }
    Something like that ?
    Spidey out!

  3. #3
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Quote Originally Posted by C_ntua View Post
    I am wondering what are my options when I want to do to jobs "simultaneously". In more words I would like for example (on a window):
    -Every x seconds a square moves forward
    -If you press a button a square stops

    What is the way to go? I can think of a lot of ways to do it in a more "simple" language (like C) but I am more interested in actual code and functions. Like doing the job simple and efficiently

    Merci beacoup (sp? its been years...)
    How about just a Timer. Pretty simple to use although don't expect extremely high resolution. The nice thing about a Timer is behind the scenes it's just WM_TIMER messages, so you don't need to worry about marshalling gui editing code to the owning thread.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dont Kill Focus When Switching Tasks
    By stickman in forum Windows Programming
    Replies: 6
    Last Post: 11-17-2006, 09:08 PM
  2. Semaphores, OS tasks
    By Rennor in forum Networking/Device Communication
    Replies: 6
    Last Post: 08-24-2006, 10:58 PM
  3. simultaneous equations
    By nic_elmo_13 in forum C Programming
    Replies: 3
    Last Post: 04-14-2003, 08:11 AM
  4. c++ tasks ??
    By tcr8008 in forum C++ Programming
    Replies: 3
    Last Post: 10-18-2002, 02:02 PM
  5. removing default tasks?
    By Scourfish in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 03-19-2002, 12:36 PM