private void HandleNewValueTask(NewValueRegisteredEventArgs e) { var valueMsg = $"\"ID\":{e.Id},\"Value\":\"{e.Value,3}\",\"Timestamp\":\"{e.RegistrationTime}\""; Parallel.ForEach(_sendValuesService.Subscriptions, new ParallelOptions() { MaxDegreeOfParallelism = 4 }, subscription => { if (subscription.Value.Contains(e.Id)) { _hubContext.Clients.Client(subscription.Key).SendCoreAsync("NewValue", new[] { valueMsg }); } }); }
private void OnNewValueRegistered(object sender, NewValueRegisteredEventArgs e) { _ = Task.Run(() => HandleNewValueTask(e)); }