Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7879457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:54:09+00:00 2026-06-03T03:54:09+00:00

How long is a single spin in c#? What I want to know is

  • 0

How long is a single spin in c#? What I want to know is there is a ManualResetEventSlim that has a spinCount parameter and I want to know how long each spin is in milliseconds or how it works? I know spinning is more efficient for short waits than a kernel wait. So I am just trying to see what I should set this value to for a job that generally takes 2-10 sec.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:54:10+00:00Added an answer on June 3, 2026 at 3:54 am

    There is no correlation between spinCount parameter in the constructor and the number of milliseconds spent doing a spin wait.

    Here is how it works. MRES uses this spinCount parameter to go through its own waiting routine independent of Thread.SpinWait.

    • The first 10 iterations alternate between calling Thread.Yield and Thread.SpinWait. The call to Thread.SpinWait starts with a spin of Environment.ProcessorCount * 4 and then approximately doubles on each successive call.
    • Thereafter each iteration divisible by 20 calls Thread.Sleep(1).
    • Otherwise those divisible by 5 call Thread.Sleep(0).
    • Otherwise Thread.Yield is called.
    • The CancellationToken is checked every 10 iterations after 100.

    So as you can see there is a fairly complex song-and-dance going on inside MRES’s custom spinning routine. And the algorithm could change from version to version. There is really no way to predict how long each spin will last.

    If your typical wait times are 2-10 seconds then your code is almost certainly going to do a kernel level wait via Monitor.Wait and Monitor.Pulse coordinations because the spinCount parameter is limited to 2047 anyway.

    Plus, 2-10 seconds is a long time. Do you really want to spin that long?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long single-line CSS file that I would like to convert using
According to Single-Threaded Application with Long-Running Calculation MSDN example, there is a possibility of
I have a single crystal report that usually ends up about 150 pages long.
One of the things that has long bugged me about the FileSystemWatcher is the
I have a web app which has a single long running task - generating
I have a DotNetNuke skin that has a single CSS file over 3,500 lines
Is there a decent way to declare a long single line string in C#,
I've a single statement running on WPF application that takes a long time (by
I've got a single-row, 40 column-long DataGridView that i need to print. Since i
I'm repeatedly merging 10000 sorted lists into a single long sorted list. Each list

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.