private void despacharEventosLOA(object sender, HBLivroOfertasAgregadoEventArgs args) { try { string mensagem = null; EventoHBLivroOfertasAgregado 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); } }
private void procHBQueueLOA() { long lstEvent = 0; logger.Info("Inicializando thread do processamento da fila de eventos de Livro de Ofertas Agregado HomeBroker"); while (bKeepRunning) { try { EventoHBLivroOfertasAgregado e; if (queueHBLOA.TryDequeue(out e)) { if (OnEventoHBLivroOfertasAgregado != null) { HBLivroOfertasAgregadoEventArgs args = new HBLivroOfertasAgregadoEventArgs(); args.Evento = e; OnEventoHBLivroOfertasAgregado(this, args); } if (MDSUtils.shouldLog(lstEvent)) { lstEvent = DateTime.UtcNow.Ticks; logger.Info("Fila queueHBLOA: " + queueHBLOA.Count + " eventos."); } continue; } lock (syncQueueHBLOA) { Monitor.Wait(syncQueueHBLOA, QUEUE_WAIT_TIMEOUT); } } catch (Exception ex) { logger.Error("procHBQueueLOA: " + ex.Message, ex); } } }