Thread: Sleep or Idle

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    589

    Sleep or Idle

    I kinda started this in another thread but I think I better start my own instead of hijacking someone elses thread

    Well..I will do my best to explain what I try to achive. I have a SDI app that is supposed to be a CAD/CAM prog. I have designed a class for getting locations from the drawing area like endpoints,centerpoints, midpoints on lines and arcs.. I want to be able to call a function in my custom class that returns XYZ coordinates. I also want to use OnMouseMove() in my custom class. But if I call the function in my class like this. m_MyClass.XYZFunction I don't get a chance to use the OnMouseMove in MyClass because XYZFunction returns right away. I could just do a forever loop but I also have some processing going on with my MyClass::OnMouseMove function so if I start spinning a loop that will take all the CPU power. So I rather use a Sleep or some sort of idle to stop XYZFunction to end before a condition in MyClass::OnMouseMove is satisfed. Did this make sense? I hope it did
    ~Barjor

  2. #2
    Registered User
    Join Date
    Feb 2002
    Posts
    589
    What I could do is to do a forever loop with a Sleep(50) in it wich would be easy on the CPU and still stop the XYZFunction from returning until some condition is meet. But thats not a pretty solution

  3. #3
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,829
    >>> Did this make sense?

    No. Try again, leave out the details, just the concept.
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  4. #4
    Registered User
    Join Date
    Feb 2002
    Posts
    589

    Barjor

    I got it to work last night without any Sleep or other cludges. I looked in my Petzold and found some cool real time calls for Lbutton down(::KeyAsyncsomething something(VK_LBUTTON)) that is negative when L mouse button is clicked and it doesn't wait for the message loop. Thanks for the interest and you where right when you said my first design was flawed. Isn' it funny how things that sounds perfectly clear when you explain something sounds like latin for people that haven't worked on your project for a year.
    ~Barjor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. [pthread] cancellable sleep in win32?
    By cyberfish in forum C++ Programming
    Replies: 2
    Last Post: 08-11-2007, 02:30 AM
  2. Sleep works with just one thread, but not 2
    By finkus in forum C++ Programming
    Replies: 5
    Last Post: 12-01-2005, 09:17 PM
  3. Problem with Sleep() #$@^#$%^
    By intruder in forum C++ Programming
    Replies: 8
    Last Post: 10-11-2004, 06:46 AM
  4. why do we require sleep?
    By jinx in forum A Brief History of Cprogramming.com
    Replies: 43
    Last Post: 07-14-2004, 08:21 AM
  5. Sleep is overrated...
    By Polymorphic OOP in forum A Brief History of Cprogramming.com
    Replies: 24
    Last Post: 01-24-2003, 12:40 PM