Encapsulates callback parameters for property CallBackOnRequest and CallBackOnResponse.
Namespace:
RRAutoLib.LoconetAssembly: RRAutoLib (in RRAutoLib.dll) Version: 1.3.3371.40749 (1.3.0.0)
Syntax
| Visual Basic (Declaration) |
|---|
Public NotInheritable Class CallBack |
Remarks
The constructor of this class take two parameters. The first is the method delegate of type LoconetService..::.RxPacketHandler to be invoked and the second is the object to synchronize the method invocation on.
Examples
In the following example, when the RequestSlot method is called, a PkReqSlotData packet is sent to the network.
When the Loconet interface echoes back indicating that the packet has been sent, Method1
is called passing the sent packet as a parameter. If and when a coresponding response
packet is received, Method2 is called passing the response packet as a parameter.
Both method callbacks are synchronized on the thread of the SampleForm since we
passed its reference in the constructor of Packet..::.CallBack.
CopyVB.NET
Imports RRAutoLib.Loconet Public Class SampleForm Inherits System.Windows.Forms.Form Private _objLoconetService As New LoconetService Private Sub RequestSlot(ByVal bytSlot As Byte) Dim objPacket As New PkReqSlotData(bytSlot) objPacket.CallBackOnRequest = New Packet.CallBack(AddressOf Method1, Me) objPacket.CallBackOnResponse = New Packet.CallBack(AddressOf Method2, Me) 'assumes _objLoconetService has been configured and started elsewhere _objLoconetService.TxPacket(objPacket) End Sub Private Sub Method1(ByVal objPacket As Packet) MsgBox(objPacket.Description) End Sub Private Sub Method2(ByVal objPacket As Packet) MsgBox(objPacket.Description) End Sub End Class