Example #1
0
        internal bool TryDequeue(string tag, out ITikSentence sentence)
        {
            if (tag == "")
                tag = EMPTY_TAG_KEY;
            lock(_lockObj)
            {
                List<ITikSentence> list;
                if (_sentencesForTags.TryGetValue(tag, out list))
                {
                    if (list.Count > 0)
                    {
                        sentence = list[0];
                        list.RemoveAt(0);

                        if (list.Count <= 0)
                            _sentencesForTags.Remove(tag); //free memory

                        return true;
                    }
                    else
                    {
                        //empty list - should not happen
                        sentence = null;
                        return false;
                    }

                }
                else
                {
                    sentence = null;
                    return false;
                }
            }
        }
Example #2
0
        internal void Enqueue(ITikSentence sentence)
        {
            lock(_lockObj)
            {
                List<ITikSentence> list;
                string sentenceTag = string.IsNullOrWhiteSpace(sentence.Tag) ? EMPTY_TAG_KEY : sentence.Tag;
                if (!_sentencesForTags.TryGetValue(sentenceTag, out list))
                {
                    list = new List<ITikSentence>();
                    _sentencesForTags.Add(sentenceTag, list);
                }

                list.Add(sentence);
            }
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TikConnectionException"/> class.
 /// </summary>
 /// <param name="message">The exception message.</param>
 /// <param name="command">The command sent to target.</param>
 /// <param name="response">The response from target.</param>
 public TikConnectionException(string message, ITikCommand command, ITikSentence response)
     : this(FormatMessage(message, command, new ITikSentence[] { response }))
 {
 }
 /// <summary>
 /// ctor.
 /// </summary>
 /// <param name="message">Exception message.</param>
 /// <param name="sentecne">Sentence with error - not proper format.</param>
 public TikSentenceException(string message, ITikSentence sentecne)
     : base(message)
 {
     _sentence = sentecne;
 }