1
Answer

stop receiving data from Serial Port.

Vasu Gadhiya

Vasu Gadhiya

8y
492
1
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)