Managing Ports and Transfers in .NET
The code to use the PinChanged event is similar to the code for the DataRe-
ceived event earlier in this chapter. The application assigns a routine to execute
when a PinChanged event occurs on an open port:
' Define a delegate class to handle PinChanged events.
Friend Delegate Sub SerialPinChangedEventHandlerDelegate _
(ByVal sender As Object, ByVal e As SerialPinChangedEventArgs)
' Create an instance of the delegate.
Private SerialPinChangedEventHandler1 _
As New SerialPinChangedEventHandler(AddressOf PinChanged)
// Define a delegate class to handle PinChanged events.
internal delegate void SerialPinChangedEventHandlerDelegate
(object sender, SerialPinChangedEventArgs e);
// Create an instance of the delegate.
private SerialPinChangedEventHandler SerialPinChangedEventHandler1;
SerialPinChangedEventHandler1 = new SerialPinChangedEventHandler(PinChanged);
The application assigns the delegate as the handler routine that will execute
when a PinChanged event occurs on an open COM port:
AddHandler myComPort.PinChanged, SerialPinChangedEventHandler1
myComPort.PinChanged += SerialPinChangedEventHandler1;