private void despacharEventos(object sender, HBNegocioEventArgs args)
        {
            try
            {
                string mensagem = null;

                EventoHBNegocio 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("despacharEventos(): " + ex.Message, ex);
            }
        }
示例#2
0
        private void procHBQueueNEG()
        {
            long lstEvent = 0;

            logger.Info("Inicializando thread do processamento da fila de eventos de Negocios HomeBroker");
            while (bKeepRunning)
            {
                try
                {
                    EventoHBNegocio e;
                    if (queueHBNEG.TryDequeue(out e))
                    {
                        if (OnEventoHBNegocios != null)
                        {
                            HBNegocioEventArgs args = new HBNegocioEventArgs();
                            args.Evento = e;
                            OnEventoHBNegocios(this, args);
                        }

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

                        continue;
                    }

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