Tom Shelton wrote:
>Is there something in C# that is similar to Java's Thread.yield?
Currently I am using the 1.1 framework.
It's been a while since I've worked with Java, but if I remember
correctly, it is giving up the current threads timeslice... If that's
the case:
Thread.Sleep(0) should do the trick.
You will want to call with a parameter of 1 instead of 0 if you want to
guarantee that the call will yield to some other thread (in particular,
a lower-priority thread).
Calling with 0 for the parameter will only allow another thread to run
if that thread is of equal or higher priority to the thread making the
call. If there's no such thread, the thread making the call will
continue to run, even if there are lower-priority threads ready and
waiting to run.
If that's not a concern, Thread.Sleep(0) should work fine.
Pete