title: serial port waiting for 13 bytes to be stored in the buffer
body: <p>I have this piece of code:</p>
  
  <pre><code>public void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
          {   
              int bytes = serial.BytesToRead;
              byte[] buffer = new byte[bytes];
              serial.Read(buffer, 0, bytes);
              foreach (var item in buffer)
              {
                  Console.Write(item.ToString());
              }
              Variables.buffering = BitConverter.ToInt64(buffer, 0);
              Console.WriteLine();
              Console.WriteLine(Variables.buffering);
              Thread thread = new Thread(new ThreadStart(() =&gt; ThreadExample.ThreadJob(this)));
              thread.Start();
              thread.Join();
  
          }
  </code></pre>
  
  <p>then I will send 13 bytes to the serial port. How will I modify this so that my program will wait for the buffer to become 13 bytes and if the buffer is 13 bytes, it should execute this one without an error:</p>
  
  <pre><code>Variables.buffering = BitConverter.ToInt64(buffer, 0);
  
  An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll 
  
  Additional information: Destination array is not long enough to copy all the items in the collection. Check array index and length.
  </code></pre>