private void procHttpQueueLOA() { long lstEvent = 0; logger.Info("Inicializando thread do processamento da fila de eventos de Livro de Ofertas Agregado Streamer"); while (bKeepRunning) { try { EventoHttpLivroOfertasAgregado e; if (queueHttpLOA.TryDequeue(out e)) { if (OnEventoHttpLivroOfertasAgregado != null) { HttpLivroOfertasAgregadoEventArgs args = new HttpLivroOfertasAgregadoEventArgs(); args.Evento = e; OnEventoHttpLivroOfertasAgregado(this, args); } if (MDSUtils.shouldLog(lstEvent)) { lstEvent = DateTime.UtcNow.Ticks; logger.Info("Fila queueHttpLOA: " + queueHttpLOA.Count + " eventos."); } continue; } lock (syncQueueHttpLOA) { Monitor.Wait(syncQueueHttpLOA, QUEUE_WAIT_TIMEOUT); } } catch (Exception ex) { logger.Error("procHttpQueueLOA: " + ex.Message, ex); } } }
private void despacharEventosLOA(object sender, HttpLivroOfertasAgregadoEventArgs args) { try { EventoHttpLivroOfertasAgregado httpLOA = args.Evento; if (dctSessions.ContainsKey(httpLOA.instrumento)) { bool sinaliza = queueEventosLOA.IsEmpty; queueEventosLOA.Enqueue(httpLOA); if (sinaliza) { lock (syncQueueEventosLOA) { Monitor.Pulse(syncQueueEventosLOA); } } } } catch (Exception ex) { logger.Error("despacharEventosLOA(): " + ex.Message, ex); } }