title: RS232 serial port communication c# win7 .net framework 3.5 sp1
body: <p>HI 
  im new in c# serial port. im writing a c# program running is winXP and win7 to keep received data from the serial port when the machine was sent data.</p>
  
  <pre><code>using System.IO;
  using System.IO.Ports;
  using System.Threading;
  
  
  namespace RS232RVR
  {
  public partial class Form1 : Form
  {
      public Form1()
      {
          InitializeComponent();
          SettingRS232();
      }
  
      public void SettingRS232 ()
      {
          try
          {
              SerialPort mySerialPort = new SerialPort("COM6");
  
              mySerialPort.BaudRate = 9600;
              mySerialPort.Parity = Parity.None;
              mySerialPort.StopBits = StopBits.One;
              mySerialPort.DataBits = 8;
              mySerialPort.Handshake = Handshake.None; //send to hardware flow control.
  
              mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceviedHandler);
  
              mySerialPort.Open();
  
  
              richTextBox1.Text = "on";
  
              mySerialPort.Close();
          }
          catch (Exception ex)
          {
              richTextBox1.Text = ex.Message;    
          }
  
      }
  
      private void DataReceviedHandler(
                      object sender,
                      SerialDataReceivedEventArgs e)
      {
          SerialPort sp = (SerialPort)sender;
          string indata = sp.ReadExisting();
          richTextBox1.Text = indata;
  
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>COM6 is active in my pc. but my problem was seem the datareceived event is not fire when it has data coming from the serial port. ( i had checked the sport by using some of the freeware application)</p>
  
  <p>anyone can help?</p>
  
  <p>thanks</p>