private async Task <CsvFileEnumerable <TRecord> > ExportAndGetRecordsFromListAsync <TRecord>(int listId,
                                                                                                     string downloadDir,
                                                                                                     ExportContext context, Func <int, string> createFileName, TimeSpan?exportTimeout,
                                                                                                     CancellationToken cancellationToken) where TRecord : CsvRecord
        {
            int?exportId             = null;
            var exportTimeoutNotNull = exportTimeout ?? TimeSpan.FromMinutes(5);

            try
            {
                var export = await _exportService.CreateAsync(listId, context, cancellationToken);

                ConnectClient.Logger.Trace($"ExportReader-ExportAndGetRecordsFromListAsync: Export {export.Id} created");

                exportId = export.Id;
                var isReady = await WaitForExportToFinishAsync(exportId.Value, exportTimeoutNotNull, cancellationToken);

                if (!isReady)
                {
                    ConnectClient.Logger.Trace($"ExportReader-ExportAndGetRecordsFromListAsync: Export {exportId} not ready in time");
                    throw new ExportIsNotCompleteException(exportId.Value);
                }

                ConnectClient.Logger.Trace($"ExportReader-ExportAndGetRecordsFromListAsync: Export {exportId} ready");

                return(await GetExportedRecordsAsync <TRecord>(exportId.Value, downloadDir,
                                                               createFileName?.Invoke(exportId.Value), cancellationToken));
            }
            finally
            {
                if (exportId.HasValue)
                {
                    await _exportService.DeleteAsync(exportId.Value, false, cancellationToken);
                }
            }
        }