Vasu Gadhiya

Vasu Gadhiya

  • NA
  • 429
  • 103.1k

stop receiving data from Serial Port.

Dec 9 2015 7:20 AM
Hello i have write code (event Handler) for get data from Serial port.

its completely fire when data is received.

but my requirement is to disable or enable data receive in between programme.
i cant stop receiving data from serial port using DisableRec Method.
class i
{
public i()
{
// ---------
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
}
void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
       {
MessageBox.Show("Data Receive");
}
public void DisableRec()
{
port.DataReceived -= new SerialDataReceivedEventHandler(this.port_DataReceived);
}
public void EnableRec()
{
port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
}
}

Answers (1)