Network Programming internal bool acceptData;
internal int myAddress = (int)'h';
private void ErrorReceived( object sender, SerialErrorReceivedEventArgs e )
{SerialError SerialErrorReceived1 = 0;
SerialErrorReceived1 = e.EventType;switch ( SerialErrorReceived1 )
{
case SerialError.RXParity:if ( ( SelectedPort.ReadChar() == myAddress ) )
{
acceptData = true;
}
else
{
acceptData = false;
}
break;
}
}
A DataReceived event can check the state of acceptData before deciding what
to do with new received data. Chapter 10 showed how to assign a method to
the DataReceived event. Friend Sub DataReceived _
(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs)
Dim newReceivedData As StringnewReceivedData = selectedPort.ReadExistingIf acceptData Then' The received address matches our address.End IfEnd Sub