Getting Thread timeslice in C#

1.2k Views Asked by At

Based on this it's clear that the framework is dynamic with it's thread timeslice based on # of processors, OS etc.

The length of the time slice depends on the operating system and the processor.

However, what's a way to get the actual thread timeslice on a given system?

We dynamically switch between Sleeping and Thread.SpinWait(x) for keeping certain timing sensitive code accurate in the sub-ms range; but need to keep that switch programmable based on the thread timeslice of the underlying system so we don't SpinWait(xxx) for too long.

So, how does one get the thread timeslice in C# (5ms, 10ms or 20ms etc)?

1

There are 1 best solutions below

0
On

The default is around 15ms, but it can be changed. You may which to take a look at the following SO question: why-are-net-timers-limited-to-15-ms-resolution