/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="handler"></param> public void Enqueue(string id, QEventHandler handler) { if (Thread.CurrentThread.ManagedThreadId == _WorkingThread.ManagedThreadId) { if (!_Stop) { try { handler(); } catch (Exception ex) { EventException?.Invoke(this, new Exception("ERROR running " + id + ": " + ex.Message)); //throw new Exception("ERROR running " + id + ": " + ex.Message); } } } else { lock (_Queue) { if (!_Stop) { _Queue.Enqueue(new Event(id, handler)); _NewEvent.Set(); } } } }
public void Enqueue(string id, QEventHandler handler) { if (Thread.CurrentThread.ManagedThreadId == _WorkingThread.ManagedThreadId) { if (!_Stop) { try { handler(); } catch (Exception x) { LogManager.GetCurrentClassLogger().Error("Event Queue ERROR {1} ejecutando {0}", id, x.Message); } } } else { lock (_Queue) { if (!_Stop) { _Queue.Enqueue(new Event(id, handler)); _NewEvent.Set(); string listaEventos = ""; if (_Queue.Count > _OverloadThreshold) { //Do not print too much if (_Queue.Count % 100 == 0 && _Queue.Count < 1000) { LogManager.GetCurrentClassLogger().Info("Event Queue {1} overloaded {0} with {2}", _Queue.Count, _Name, id); foreach (Event evento in _Queue.ToArray()) { listaEventos += " "; listaEventos += evento.Id; } //LogManager.GetCurrentClassLogger().Trace("ev:{0} ", listaEventos); } } } } } }
public Event(string id, QEventHandler handler) { Id = id; Handler = handler; Valid = true; }
public void RegisterEventHandler(QEventHandler qev) { _port.QEvents += qev; }