Hi there,
in my App I’ve got a Subclass of the UDPSocket. The Socket has the following in its DataAvailable Handler + some condition checking, not shown here:
[code] Dim d As Datagram
Dim mb As MemoryBlock
d = Me.Read // Read Datagram as soon as it is available
mb = d.data // Read Datagram into a MemoryBlock so we can parse it Bytewise
mPacketsReceived = mPacketsReceived+1
mPacketsSent = mPacketsSent +1
mReceivedPacket ( mb, d.Address )[/code]
The function mReceivedPacket does this:
MyClass(mb.uInt16Value ( 14 )).mb = mb
DataReceived(Address, MyClass(mb.uInt16Value ( 14 ))) //Firing Event Handler
The dataAvailable Handler beforehand checks if several conditions have been met, so its save to assume that uInt16Value(14) is what it needs to be.
MyClass is doing the folliwing the setter of the mb variable:
[code] if value <> mmb then
mmb = value
setValues.Run
end[/code]
Whereas setValues is a Thread. This all works well, despite the fact that in mReceivedPacket the line “MyClass(mb.uInt16Value ( 14 )).mb = mb” takes up to 4ms, and thus prevents the dataAvailable from being able to fire as fast as it would need to be, which in return means the delay is adding up until packets get lost because the buffer of the UDPSocket runs full.
Now and finally… My question:
Why is this taking so long? Because it is not pointing to the original MB, but instead creating a new instance, or at least assigning a new value to a different instance of the memoryblock?
And what could I do to avoid this issue?
Cheers and thanks once again, you guys rock!
Denis