Hi, I'm using a hashtable to buffer incoming messages from remote clients. However, I have found instances where the hash value of the key when being stored is different to that of the same string when retrieving. However, some instances of retrieving pairs is successful. The 2 snippets below show the store and retrieval mechanisms. An example key to store would be "192.168.1.123:<07x> - this is an example that, when attempting to retreive, is shown in the locals window, but containsKey returns false. Any pointers greatly appreciated.
VB.NET
PublicFunction getRecievedMessage(ByVal strIPAddress AsString, ByVal strCbusMsgID AsString) AsStringDim strKey AsString = strIPAddress & ":" & strCbusMsgID 'Concatenate IP and ID to form keyDim strCbusMsg AsStringIfMe.qCbusMessageList.Contains(strKey) Then'The requested message has been received; return its value and delete from the collection
strCbusMsg = Me.qCbusMessageList.Item(strKey)
Me.qCbusMessageList.Remove(strKey)
Return strCbusMsg
Else'The requested message has not been recievedReturnNothingEndIfEndFunctionPrivateSub listenCbusIn()
Dim strcCbusMsg As CbusMsgContainer
WhileTrue'Loop continuously
strcCbusMsg = Me.uIn.recCbus()
IfNot strcCbusMsg IsNothingThen'CBus Message received, add to listDim strIP AsString = strcCbusMsg.getIp
Dim strID AsString = strcCbusMsg.getId
Dim strKey AsString = strIP & ":" & strID
Me.qCbusMessageList.Add(strcCbusMsg.getIp & ":" & strcCbusMsg.getId, strcCbusMsg.getMsg)
EndIfEndWhileEndSub
Code
Code
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Brendon Frater2 reputationPosted Feb 4, 2010, 11:40 AM EST
I am having the exact same issue.