private void despacharEventosLOF(object sender, HBLivroOfertasEventArgs args)
        {
            try
            {
                string mensagem = null;

                EventoHBLivroOfertas eventoHB = args.Evento;
                mensagem = eventoHB.mensagem;

                if (!String.IsNullOrEmpty(mensagem))
                {
                    bool sinaliza = queueToHomeBroker.IsEmpty;
                    queueToHomeBroker.Enqueue(mensagem);
                    if (sinaliza)
                    {
                        lock (syncObj)
                        {
                            Monitor.Pulse(syncObj);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("despacharEventosLOF(): " + ex.Message, ex);
            }
        }
示例#2
0
        private void procHBQueueLOF()
        {
            long lstEvent = 0;

            logger.Info("Inicializando thread do processamento da fila de eventos de Livro de Ofertas HomeBroker");

            while (bKeepRunning)
            {
                try
                {
                    EventoHBLivroOfertas e;
                    if (queueHBLOF.TryDequeue(out e))
                    {
                        if (OnEventoHBLivroOfertas != null)
                        {
                            HBLivroOfertasEventArgs args = new HBLivroOfertasEventArgs();
                            args.Evento = e;
                            OnEventoHBLivroOfertas(this, args);
                        }

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

                        continue;
                    }

                    lock (syncQueueHBLOF)
                    {
                        Monitor.Wait(syncQueueHBLOF, QUEUE_WAIT_TIMEOUT);
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("procHBQueueLOF: " + ex.Message, ex);
                }
            }
        }