Created
August 13, 2025 14:17
-
-
Save dadhi/5d39ad164b2a68344a19d151e9b0e1ae to your computer and use it in GitHub Desktop.
ThreadSleepYieldMeaning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // source: https://github.com/dotnet/runtime/discussions/115627#discussioncomment-14092390 | |
| // Thread.Sleep(0); // 4750 cede control to any thread of equal priority | |
| // spinWait.SpinOnce(); // 4100 periodically yields (default is 10 iterations) | |
| // Thread.Sleep(1); // 3900 cede control to any thread of OS choice | |
| // Thread.Yield(); // 3650 cede control to any thread on the same core | |
| // await Task.Delay(0); // 3600 creates and waits on a system timer | |
| // do nothing // 3600 burn down a CPU core | |
| // Thread.SpinWait(1); // 3600 duration-limited Yield | |
| // await Task.Yield(); // 3250 suspend task indefinitely (scheduler control) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment