internal void Run() { Cts = new CancellationTokenSource(); var stillStartedEvent = new StillStartedEvent(Id); Kafka.ProduceEventAsJson(nameof(StillStartedEvent), stillStartedEvent); Task = Task.Run <Task>( function: ProduceRandomSensorData, cancellationToken: Cts.Token); }
private static void HandleStillStartedEvent(StillStartedEvent ev) { stillStatusDictionary.AddOrUpdate(key: ev.StillId, addValue: new StillStatus() { Id = ev.StillId, Started = ev.Occured, LastSeen = ev.Occured }, updateValueFactory: (stillId, item) => { return(new StillStatus() { Id = item.Id, Started = ev.Occured, LastSeen = ev.Occured > item.LastSeen ? ev.Occured : item.LastSeen }); }); }
private static void HandleStillStartedEvent(StillStartedEvent ev) { Misc.WriteLineInColor($"{DateTime.Now:yyyy/MM/dd hh:mm:ss.fff}: Still with id {ev.StillId} started at {ev.Occured:yyyy/MM/dd hh:mm:ss.fff}", ConsoleColor.Green); }