Beispiel #1
0
        /// <summary>
        /// Get the data from listInput, deserialize it and put the result in listOutput
        /// </summary>
        /// <param name="listInput">List of bytes array</param>
        /// <param name="listOutput">List with MessageTick objects</param>
        /// <param name="t"></param>
        private static void Execute(Object listInput, Object listOutput, Object t)
        {
            if ((listInput is BlockingCollection <byte[]>) && (listOutput is BlockingCollection <MessageTick>))
            {
                var deserialize = DefaultMessageTickPackSerializationFactory.Instance.Create();
                BlockingCollection <byte[]>      listSource = (BlockingCollection <byte[]>)listInput;
                BlockingCollection <MessageTick> listDest   = (BlockingCollection <MessageTick>)listOutput;

                DeserializeTicks thread = (DeserializeTicks)t;
                thread.isWorking = true;
                while (thread.isWorking)
                {
                    byte[] tmp = null;
                    if (listSource.TryTake(out tmp, TimeSpan.FromMilliseconds(10)))
                    {
                        //deserialize and put in listDest
                        thread.m_totalObjectDeserialized++;

                        MessageTickPack messageTickPack = deserialize.Deserialize(tmp);

                        foreach (MessageTick mt in messageTickPack.MessageTicks)
                        {
                            listDest.Add(mt);
                            DeserializeTicks.TotalDesObjects++;
                        }

                        if (listSource.Count == 0)
                        {
                            Thread.Sleep(50);
                        }
                    }
                    else
                    {
                        Thread.Sleep(50);
                    }
                }
            }
        }
Beispiel #2
0
 private void ExecuteMethod(BlockingCollection <byte[]> listInput, BlockingCollection <MessageTick> listOutput, DeserializeTicks thread)
 {
     DeserializeTicks.Execute(listInput, listOutput, thread);
 }