private async Task CloseAllOpenedSessions() { while (_activeLapJobs > 0) { await Task.Delay(100); } foreach (LapTelemetryDto value in _cachedTelemetries.Values) { await UnloadLap(value.LapSummary); } _loadedSessions.ForEach(x => _telemetryRepository.CloseSession(x)); _loadedSessions.Clear(); _knownLaps.Clear(); }