Jump to content


yield execution to another process in windows


2 replies to this topic

#1 john

    Member

  • Members
  • PipPip
  • 84 posts

Posted 18 January 2007 - 07:45 AM

How do you tell the OS in windows to process another thread or process, which is useful when your app is processor-extensive? Sort of like the DoEvents in Visual Basic. I'm sure there is a Win32 API for that. Tried searching, but couldn't find anything.

#2 Dia

    DevMaster Staff

  • Administrators
  • 1121 posts

Posted 18 January 2007 - 07:51 AM

There's an API called SwitchToThread()

You could also call Sleep(0), which should yield to any thread that has the same or higher priority.

#3 pater

    Valued Member

  • Members
  • PipPipPip
  • 117 posts

Posted 18 January 2007 - 09:01 PM

Or, if you need to perform longer cpu-power expensive tasks (but nothing time-critical), you could also just lower your own process or task priority. That way, you can get as much CPU time as you want, without disturbing any other process/thread. All applications will stay responsive and act as if nothing was special, but you can use all the "idle" time without you having to periodically call Sleep().





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users