private void ConnectionManager_OnReceived(object sender, RXReceiveMessage e)
 {
     if (e.RXConnection.RemoteRXDevice == RemoteRXDevice && e.ChannelCode == ATTRIBUTE_CHANNEL_CODE)
     {
         var response = AttributeReadResult.DecodeFromByteArray(e.Bytes);
         lock (_WaitingThreadDictLock)
         {
             if (_WaitingThreadDict.ContainsKey(response.RequestGuid))
             {
                 var bundle = _WaitingThreadDict[response.RequestGuid];
                 bundle.Result = response;
                 bundle.Thread.Interrupt();
             }
         }
     }
 }
 public Task <AttributeReadResult> ReadAsync(string attributeKey)
 {
     return(Task.Run(() =>
     {
         Guid requestGuid = Guid.NewGuid();
         AttributeReadRequest readRequest = new AttributeReadRequest
         {
             RequestKey = attributeKey,
             RequestGuid = requestGuid
         };
         var sendMsg = new RXSendMessage()
         {
             ChannelCode = ATTRIBUTE_CHANNEL_CODE,
             Bytes = readRequest.EncodeToBytesArray()
         };
         lock (_WaitingThreadDictLock)
         {
             _WaitingThreadDict.Add(requestGuid, new ThreadResponseBundle {
                 Thread = Thread.CurrentThread
             });
         }
         var sendTask = RemoteRXDevice.ConnectionManager.SendAsync(sendMsg);
         AttributeReadResult result;
         try
         {
             Thread.Sleep(SessionTimeOutInMs);
             result = new AttributeReadResult
             {
                 RequestGuid = requestGuid,
                 ReadState = AttributeReadState.Error
             };
         }
         catch (ThreadInterruptedException)
         {
             lock (_WaitingThreadDictLock)
             {
                 result = _WaitingThreadDict[requestGuid].Result;
             }
         }
         finally
         {
             _WaitingThreadDict.Remove(requestGuid);
         }
         return result;
     }));
 }