async Task StreamingWriter(ChannelWriter <IDictionary <string, object> > writer, IDictionary <string, object> sentData, int count, int streamItemWaiting) { Exception localException = null; try { for (var i = 0; i < count; i++) { sentData[SignalRConstants.Timestamp] = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString(); await writer.WriteAsync(sentData); if (streamItemWaiting > 0) { await Task.Delay(streamItemWaiting); } // Update statistics SignalRUtils.RecordSend(sentData, StatisticsCollector); } } catch (Exception ex) { localException = ex; } writer.Complete(localException); }