CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2004
    Posts
    133

    Question A thread problem...

    Hi all

    How can we make the Sleep(milliseconds) function to be more
    accurate.i:e if it is Sleep(500), The Thread should wakeup exactly after
    500ms. I need this to be implemented in workerthread.

    Your valueable suggestions are welcome.


    regards
    pradish

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: A thread problem...

    [ Redirected thread ]
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: A thread problem...

    The Sleep function is never really accurate. Windows is not a realtime operating system. However, you might get beter accuracy with multimedia timers. Do a search for them on codeguru or google.
    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

  4. #4
    Join Date
    Nov 2004
    Posts
    133

    Question Re: A thread problem...

    Quote Originally Posted by Marc G
    you might get beter accuracy with multimedia timers.
    But how do i replace this with sleep() function in a worker thread



    regards
    pradish

  5. #5
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,150

    Re: A thread problem...

    Marc Gregoire - NuonSoft (http://www.nuonsoft.com)
    My Blog
    Wallpaper Cycler 3.5.0.97

    Author of Professional C++, 4th Edition by Wiley/Wrox (includes C++17 features)
    ISBN: 978-1-119-42130-6
    [ http://www.facebook.com/professionalcpp ]

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