CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 1999
    Posts
    53

    How do I make a wait() which doesn't use all processor time while waiting?

    I need a wait(float seconds) function.
    This is one alternative:

    #include <time.h>

    void wait(float seconds)
    {
    long waitingTime = seconds * CLOCKS_PER_SEC;
    clock_t goal = waitingTime + clock();
    while (goal > clock());
    }



    But this function consumes all processor time. I need a function that does the same thing, but does not consume all processor time. Can somebody help me?

    Thank you.


  2. #2
    Join Date
    Apr 1999
    Posts
    42

    Re: How do I make a wait() which doesn't use all processor time while waiting?

    Use Sleep() or SleepEx() API calls.

    Martin van den Berg
    High Tech Automation
    The Netherlands
    [email protected]

  3. #3
    Join Date
    Apr 1999
    Posts
    64

    Re: How do I make a wait() which doesn't use all processor time while waiting?

    Email me at [email protected] and I will send you a routine.

    Phil McGahan
    (303) 252-8889
    12100 Elizabeth St.
    Thornton, Colorado 80241

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured