title: Recording with NAudio using C#
body: <p>I am trying to record audio in C# using NAudio. After looking at the NAudio Chat Demo, I used some code from there to record.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>using System;
  using NAudio.Wave;
  
  public class FOO
  {
      static WaveIn s_WaveIn;
  
      static void Main(string[] args)
      {
          init();
          while (true) /* Yeah, this is bad, but just for testing.... */
              System.Threading.Thread.Sleep(3000);
      }
  
      public static void init()
      {
          s_WaveIn = new WaveIn();
          s_WaveIn.WaveFormat = new WaveFormat(44100, 2);
  
          s_WaveIn.BufferMilliseconds = 1000;
          s_WaveIn.DataAvailable += new EventHandler&lt;WaveInEventArgs&gt;(SendCaptureSamples);
          s_WaveIn.StartRecording();
      }
  
      static void SendCaptureSamples(object sender, WaveInEventArgs e)
      {
          Console.WriteLine("Bytes recorded: {0}", e.BytesRecorded);
      }
  }
  </code></pre>
  
  <p>However, the eventHandler is not being called. I am using .NET version 'v2.0.50727' and compiling it as:</p>
  
  <pre><code>csc file_name.cs /reference:Naudio.dll /platform:x86
  </code></pre>