title: C# - using Thread.Sleep() to get my cycle run several hundred times per second
body: <p>I am developing an application which analyses real-time financial data. Currently my main computational cycle has the following design:</p>
  
  <pre><code>long cycle_counter=0;
  while (process_data)
  {
    (analyse data, issue instruction - 5000 lines of straightforwasrd code with computations)
    cycle_counter++;
    Thread.Sleep(5);
  }
  </code></pre>
  
  <p>When I run this application on my notebook  (one Core i5) processor, the cycle runs 200-205 times per second - a sort of as expected (if you don't bother about why it runs more than 200 times a second). </p>
  
  <p>But when I deploy the application on "real" workstation, which has 2 6-core Xeon processors and 24 GB of fast RAM, and which loads Win7 in about 3 seconds, the application runs the cycle about 67 times per second. </p>
  
  <p>My questions are:</p>
  
  <ul>
  <li><p>why is this happening?</p></li>
  <li><p>how can I influence the number of runs per second in this situation?</p></li>
  <li><p>are there any better solutions for running the cycle 200-1000 times per second? I am now thinking about just removing Thread.Sleep() (the way I use it here is criticised a lot). With 12 cores I have no problems using one core just for this cycle. But there my be some downside to such solution?</p></li>
  </ul>
  
  <p>Thank you for your ideas.</p>