title: Reading from serial port asynchronously using Async await method
body: <p>I'm using this way for reading from serial port :</p>
  
  <pre><code>public static void Main()
  {
      SerialPort mySerialPort = new SerialPort("COM1");
  
      mySerialPort.BaudRate = 9600;
      mySerialPort.Parity = Parity.None;
      mySerialPort.StopBits = StopBits.One;
      mySerialPort.DataBits = 8;
      mySerialPort.Handshake = Handshake.None;
  
      mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
  
      mySerialPort.Open();
  
      Console.WriteLine("Press any key to continue...");
      Console.WriteLine();
      Console.ReadKey();
      mySerialPort.Close();
  }
  private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
  {
      SerialPort sp = (SerialPort)sender;
      string indata = sp.ReadExisting();
      Debug.Print("Data Received:");
      Debug.Print(indata);
  }
  </code></pre>
  
  <p>as we know This kind of API is called the Event-based Asynchronous Pattern (EAP), I want to write above code using Async Await method.</p>
  
  <p>PS : with above code sometime I'm getting wrong data<br>
  <strong>Thanks in Advance</strong></p>