public override Task HandleEvent(StateEvent state) { return(Task.Run(() => { _logger.Info("Reader {0} is {1}", state.SenderId, state.State); })); }
public override Task HandleEvent(StateEvent state) { return(Task.Run(() => { _logger.Info("ID = {0} - State = {1}", state.SenderId, state.State); if (state.State.Equals(CollectorConstants.STATE_PUBLISHER_DONE)) { _logger.Info("Stack complete, killing the stack."); } })); }
/// <summary> /// Signal a state event /// </summary> /// <param name="state">The state</param> /// <returns>A task</returns> public Task SignalEvent(StateEvent state) { // Check if we need to unload the handlers for this sender. _logger.Debug("Event state signaled by {0}, state is {1}", state.SenderId, state.State); _sema.WaitOne(); if (!_events.ContainsKey(state.SenderId)) { _events.Add(state.SenderId, new List <StateEvent>()); } else { _events[state.SenderId].Add(state); } if (state.State == CollectorConstants.STATE_READER_DONE) { if (_stacks.ContainsKey(state.SenderId)) { var stack = _stacks[state.SenderId]; bool allDone = true; foreach (var publisher in stack.Publishers) { if (!publisher.Done) { allDone = false; break; } } stack.Done = allDone; } } _sema.Release(); // Let the implementation have a go... return(HandleEvent(state)); }
/// <summary> /// Handle a state event /// </summary> /// <param name="state">The state to handle</param> /// <returns>A task</returns> public abstract Task HandleEvent(StateEvent state);