public TailListenerThread(int id, ITailCallback callback, ITailStreamListener listener, ITailStreamContext context) { _id = id; _callback = callback; _listener = listener; _context = context; _stopSignal = new ManualResetEvent(false); _stoppedSignal = new ManualResetEvent(false); _thread = new Thread(Execute); _thread.IsBackground = true; }
public StartListeningEvent(ITailStreamListener listener, ITailStreamContext context) { if (listener == null) { throw new ArgumentNullException("listener"); } if (context == null) { throw new ArgumentNullException("context"); } _listener = listener; _context = context; }
public void Start(ITailStreamListener streamListener, ITailStreamContext streamContext) { lock (_lock) { // Create the thread. var id = Interlocked.Increment(ref _counter); // Notify about a new thread. _eventAggregator.Publish(new StartedListeningEvent(id, streamContext.GetDescription(), streamContext.GetName())); // Initialize the listener. streamListener.Initialize(streamContext); // Create the thread. var callback = new TailListenerThreadCallback(id, Publish); var thread = new TailListenerThread(id, callback, streamListener, streamContext); thread.Start(); _logger.Information("Created thread with id #{0} ({1}).", id, streamContext.GetDescription()); // Add the thread to the collection. _threads.Add(thread); } }
public void RegisterListener(Type type, ITailStreamListener streamListener) { _listenerFactories.Add(type, streamListener); }