private void parseResponse(object obj)
#endif
        {
            while (true)
            {
                try
                {
                    ViscaRxPacket rxPacket = _responseQueue.Dequeue();
                    if (rxPacket == null)
                    {
                        logMessage(2, "Exception in parseResponse thread, deque byte array is null");
                        break;
                    }

                    //if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
                    logMessage(2, "Response '{0}' Dequeued. ResponseQueue Size: {1}",
                               rxPacket.ToString(),
                               //String.Concat(message.Select(b => string.Format(@"[{0:X2}]", (int)b)).ToArray()),
                               _responseQueue.Count);

                    if (rxPacket.IsNetworkChange)
                    {
                        // TODO: rxPacket.IsNetworkChange not sure what shall we doo
                        continue;
                    }
                    else if (rxPacket.IsClearBroadcast)
                    {
                        // TODO: rxPacket.IsClearBroadcast not sure what shall we doo
                        continue;
                    }


                    if (_sendQueueCommandInProgress == null)
                    {
                        /// response is not associated with any particular command
                        logMessage(2, "Collision, response for command not in progress");
                    }
                    else
                    {
#if SSHARP
                        _sendQueueItemInProgressTimer.Stop();
#else
                        _sendQueueItemInProgressTimer.Change(Timeout.Infinite, Timeout.Infinite);
#endif
                        if (rxPacket.IsAck)
                        {
                            _socketInProgress = rxPacket.Socket;
                            logMessage(1, "Command '{0}' accepted on socket '{1}'", _sendQueueCommandInProgress.ToString(), _socketInProgress.Value);
                            continue;
                        } // rxPacket.IsAck
                        else if (rxPacket.IsCompletionCommand)
                        {
                            if (!_sendQueueCommandInProgress.IsCommand)
                            {
                                logMessage(2, "Collision, completion message is not for Command type message");
                            }
                            ViscaCommand command = _sendQueueCommandInProgress as ViscaCommand;
                            if (command != null && command.CompletionAction != null)
                            {
                                command.CompletionAction();
                            }
                        } // rxPacket.IsCompletionCommand
                        else if (rxPacket.IsCompletionInquiry)
                        {
                            // we have pending clearance command in progress, use it's processing hook
                            var query = _sendQueueCommandInProgress as ViscaInquiry;
                            if (query != null)
                            {
                                query.Process(rxPacket);
                            }
                            else
                            {
                                logMessage(2, "Collision, expecting ViscaInquiry type as command in progress");
                            }
                        } // rxPacket.IsCompletionInquiry
                        else if (rxPacket.IsError)
                        {
                            // Error message
                            switch (rxPacket.Error)
                            {
                            case ViscaError.Length:
                                // Message Length Error
                                logMessage(2, "Error from device: Message Length Error");
                                break;

                            case ViscaError.Syntax:
                                // Syntax Error
                                logMessage(2, "Error from device: Syntax Error");
                                break;

                            case ViscaError.Full:
                                // Command Buffer Full
                                logMessage(2, "Error from device: Command Buffer Full");
                                break;

                            case ViscaError.Canceled:
                                // Command Cancelled
                                logMessage(2, "Error from device: Command Cancelled");
                                break;

                            case ViscaError.NoSocket:
                                // No Socket
                                logMessage(2, "Error from device: No Socket");
                                break;

                            case ViscaError.NotExecutable:
                                // Command not executable
                                logMessage(2, "Error from device: Command not executable");
                                break;
                            }
#if SSHARP
                            if (_sendQueueCommandInProgress.ErrorAction != null)
                            {
                                _sendQueueCommandInProgress.ErrorAction(rxPacket.Error);
                            }
#else
                            _sendQueueCommandInProgress.ErrorAction?.Invoke(rxPacket.Error);
#endif
                        } // rxPacket.IsError
                        else
                        {
                            logMessage(1, "Error: unknown packet type");
                        }

                        logMessage(2, "Completing command in progress: '{0}'", _sendQueueCommandInProgress.ToString());
                        _sendQueueCommandInProgress = null;
                        _socketInProgress           = null;
                    }
                }
#if SSHARP
#else
                catch (OperationCanceledException)
                {
                    logMessage(2, "Visca Response Queue shutdown");
                    break;
                }
#endif
                catch (Exception e)
                {
                    logMessage(2, "Exception in parseResponse thread: '{0}'\n{1}", e.Message, e.StackTrace);
                }

                if ((_sendQueue.Count > 0) && (_responseQueue.Count == 0))
                {
                    sendNextQueuedCommand();
                }
            } // while(true)
#if SSHARP
            return(null);
#else
            return;
#endif
        }