Callback payload for packet events.

Namespace: RRAutoLib.Loconet
Assembly: RRAutoLib (in RRAutoLib.dll) Version: 1.4.4420.16901

Syntax

C#
public sealed class CallBack
Visual Basic
Public NotInheritable Class CallBack

Remarks

Encapsulates callback parameters for property CallBackOnEcho and CallBackOnResponse.

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 back to the calling thread.
CopyVB.NET
Imports RRAutoLib.Loconet
Imports RRAutoLib.Common

Public Class Sample        

    Private _objLoconetService As New LoconetService

    Public Sub RequestSlot(ByVal bytSlot As Byte)
        Dim objPacket As New PkReqSlotData(bytSlot)
        objPacket.CallBackOnEcho = New Packet.CallBack(AddressOf Method1, New SyncContext())
        objPacket.CallBackOnResponse = New Packet.CallBack(AddressOf Method2, New SyncContext())

        'assumes _objLoconetService has been previously initialized and started
        _objLoconetService.TxPacket(objPacket)
    End Sub

    Private Sub Method1(ByVal objPacket As Packet)
        Console.WriteLine(objPacket.Description)
    End Sub

    Private Sub Method2(ByVal objPacket As Packet)
        Console.WriteLine(objPacket.Description)
    End Sub

End Class

Inheritance Hierarchy

System..::..Object
  RRAutoLib.Loconet..::..Packet..::..CallBack

See Also