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.
Public Function getRecievedMessage(ByVal strIPAddress As String, ByVal strCbusMsgID As String) As String Dim strKey As String = strIPAddress & ":" & strCbusMsgID 'Concatenate IP and ID to form key Dim strCbusMsg As String If Me.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 recieved Return Nothing End If End Function Private Sub listenCbusIn() Dim strcCbusMsg As CbusMsgContainer While True 'Loop continuously strcCbusMsg = Me.uIn.recCbus() If Not strcCbusMsg Is Nothing Then 'CBus Message received, add to list Dim strIP As String = strcCbusMsg.getIp Dim strID As String = strcCbusMsg.getId Dim strKey As String = strIP & ":" & strID Me.qCbusMessageList.Add(strcCbusMsg.getIp & ":" & strcCbusMsg.getId, strcCbusMsg.getMsg) End If End While End Sub
|