Пример #1
0
        private void procHttpQueueLOF()
        {
            long lstEvent = 0;

            logger.Info("Inicializando thread do processamento da fila de eventos de Livro de Ofertas Streamer");
            while (bKeepRunning)
            {
                try
                {
                    EventoHttpLivroOfertas e;
                    if (queueHttpLOF.TryDequeue(out e))
                    {
                        if (OnEventoHttpLivroOfertas != null)
                        {
                            HttpLivroOfertasEventArgs args = new HttpLivroOfertasEventArgs();
                            args.Evento = e;
                            OnEventoHttpLivroOfertas(this, args);
                        }

                        if (MDSUtils.shouldLog(lstEvent))
                        {
                            lstEvent = DateTime.UtcNow.Ticks;
                            logger.Info("Fila queueHttpLOF: " + queueHttpLOF.Count + " eventos.");
                        }

                        continue;
                    }

                    lock (syncQueueHttpLOF)
                    {
                        Monitor.Wait(syncQueueHttpLOF, QUEUE_WAIT_TIMEOUT);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("procHttpQueueLOF: " + ex.Message, ex);
                }
            }
        }
Пример #2
0
        private void despacharEventosLOF(object sender, HttpLivroOfertasEventArgs args)
        {
            try
            {
                EventoHttpLivroOfertas httpLOF = args.Evento;

                if (dctSessions.ContainsKey(httpLOF.instrumento))
                {
                    bool bsinaliza = queueEventosLOF.IsEmpty;
                    queueEventosLOF.Enqueue(httpLOF);
                    if (bsinaliza)
                    {
                        lock (syncQueueEventosLOF)
                        {
                            Monitor.Pulse(syncQueueEventosLOF);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("despacharEventosLOF(): " + ex.Message, ex);
            }
        }