title: Serial communication in C# too slow
body: <p>I've got an issue with serial communication. My computer communicates with microcontroller via Bluetooth (HC-05) which should send some bytes of data. Everything works okay except speed of receiving data. It is late, sometimes one second, sometimes even 5-10 seconds. Baud rate was checked. Here is full code.</p>
  <pre><code>    private void Form1_Load(object sender, EventArgs e)
      {
          string[] ports = SerialPort.GetPortNames();
          comboBox1.Items.AddRange(ports);
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          serialPort1.PortName = comboBox1.Text;
          serialPort1.BaudRate = 9600;
          serialPort1.DataBits = 8;
          serialPort1.StopBits = StopBits.One;
          serialPort1.Parity = Parity.None;
  
          serialPort1.Open();
      }
  
      private void button2_Click(object sender, EventArgs e)
      {
          if (serialPort1.IsOpen)
              serialPort1.Close();
      }
  
      private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
      {
          //dataIN = serialPort1.ReadExisting();
          this.Invoke(new EventHandler(ShowData));
          int count = serialPort1.Read(buffer, 0, 1);
          dataIN = Convert.ToInt32(buffer[0]);
          
      }
      private void ShowData(object sender, EventArgs e)
      {
          
          textBox1.Text += dataIN.ToString();
          br++;
          if(br == 300)
          {
              textBox1.Text = &quot;&quot;;
              br = 0;
          }
      }
  }
  </code></pre>
  <p>}</p>