private IEnumerator RunPeriodicTelemetry() { while (session.IsValid()) { if (!jobQueue.IsEmpty) { Report.GetFunctionLog(this.GetType().Name); List <TelemetryBody> telemetryBodies = new List <TelemetryBody>(); List <ResultCallback> telemetryCallbacks = new List <ResultCallback>(); while (!jobQueue.IsEmpty) { if (jobQueue.TryDequeue(out var dequeueResult)) { telemetryBodies.Add(dequeueResult.Item1); telemetryCallbacks.Add(dequeueResult.Item2); } } yield return(this.api.SendProtectedEvents(telemetryBodies, this.session.AuthorizationToken, result => { foreach (var callback in telemetryCallbacks) { callback.Invoke(result); } })); } yield return(new WaitForSeconds((float)telemetryInterval.TotalSeconds)); } ResetTelemetryScheduler(); }