Click or drag to resize

PacketClone Method

Creates a copy of the packet.

Namespace:  RRAutoLib.Loconet
Assembly:  RRAutoLib (in RRAutoLib.dll) Version: 4.0.8678.28884
Syntax
Public Overridable Function Clone As Object

Return Value

Type: Object
A Packet object that has the same data content as the cloned packet.

Implements

ICloneableClone
Remarks
Only the following methods are cloned. The rest are initialized instead: A packet should not be altered in any way after its transmission since the Loconet service will proccess it at an indeterminant time on another thread. If you must send the same packet repeatedly, send a clone of it instead to insure packet uniqueness and immutability.
Examples
The following example shows the correct way of transmitting a packet repeatedly:
VB
'assumes LoconetService (locServ) has been previously initialized and started
Dim packet As New PkReqSlotData(3)
locServ.TxPacket(packet.Clone)
packet.Slot = 4
locServ.TxPacket(packet.Clone)
packet.Slot = 5
locServ.TxPacket(packet)
See Also