Add ConfigureAwait to awaited calls

This commit is contained in:
Claus Vium 2019-02-20 19:35:47 +01:00
parent 4a5c526ccc
commit 8af4417f8f
7 changed files with 54 additions and 24 deletions

View File

@ -64,7 +64,9 @@ namespace MediaBrowser.Providers.People
.Where(i => TvdbSeriesProvider.IsValidSeries(i.ProviderIds))
.ToList();
var infos = (await Task.WhenAll(seriesWithPerson.Select(async i => await GetImageFromSeriesData(i, item.Name, cancellationToken))))
var infos = (await Task.WhenAll(seriesWithPerson.Select(async i =>
await GetImageFromSeriesData(i, item.Name, cancellationToken).ConfigureAwait(false)))
.ConfigureAwait(false))
.Where(i => i != null)
.Take(1);
@ -77,7 +79,9 @@ namespace MediaBrowser.Providers.People
try
{
var actorsResult = await _tvDbClientManager.GetActorsAsync(tvdbId, series.GetPreferredMetadataLanguage(), cancellationToken);
var actorsResult = await _tvDbClientManager
.GetActorsAsync(tvdbId, series.GetPreferredMetadataLanguage(), cancellationToken)
.ConfigureAwait(false);
var actor = actorsResult.Data.FirstOrDefault(a =>
string.Equals(a.Name, personName, StringComparison.OrdinalIgnoreCase) &&
!string.IsNullOrEmpty(a.Image));

View File

@ -77,7 +77,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
{
// Traverse all episode pages and join them together
var episodes = new List<EpisodeRecord>();
var episodePage = await GetEpisodesPageAsync(tvdbId, new EpisodeQuery(), language, cancellationToken);
var episodePage = await GetEpisodesPageAsync(tvdbId, new EpisodeQuery(), language, cancellationToken)
.ConfigureAwait(false);
episodes.AddRange(episodePage.Data);
if (!episodePage.Links.Next.HasValue || !episodePage.Links.Last.HasValue)
{
@ -89,7 +90,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
for (var page = next; page <= last; ++page)
{
episodePage = await GetEpisodesPageAsync(tvdbId, page, new EpisodeQuery(), language, cancellationToken);
episodePage = await GetEpisodesPageAsync(tvdbId, page, new EpisodeQuery(), language, cancellationToken)
.ConfigureAwait(false);
episodes.AddRange(episodePage.Data);
}
@ -172,7 +174,9 @@ namespace MediaBrowser.Providers.TV.TheTVDB
string language,
CancellationToken cancellationToken)
{
var episodePage = await GetEpisodesPageAsync(Convert.ToInt32(seriesTvdbId), episodeQuery, language, cancellationToken);
var episodePage =
await GetEpisodesPageAsync(Convert.ToInt32(seriesTvdbId), episodeQuery, language, cancellationToken)
.ConfigureAwait(false);
return episodePage.Data.FirstOrDefault()?.Id.ToString();
}
@ -198,7 +202,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
}
_tvDbClient.AcceptedLanguage = TvdbUtils.NormalizeLanguage(language) ?? DefaultLanguage;
var result = await resultFactory.Invoke();
var result = await resultFactory.Invoke().ConfigureAwait(false);
_cache.Set(key, result, TimeSpan.FromHours(1));
return result;
}

View File

@ -63,7 +63,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
ParentIndexNumber = episode.ParentIndexNumber.Value,
SeriesProviderIds = series.ProviderIds
};
episodeTvdbId = await _tvDbClientManager.GetEpisodeTvdbId(episodeInfo, language, cancellationToken);
episodeTvdbId = await _tvDbClientManager
.GetEpisodeTvdbId(episodeInfo, language, cancellationToken).ConfigureAwait(false);
if (string.IsNullOrEmpty(episodeTvdbId))
{
_logger.LogError("Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}",
@ -73,7 +74,9 @@ namespace MediaBrowser.Providers.TV.TheTVDB
}
var episodeResult =
await _tvDbClientManager.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), language, cancellationToken);
await _tvDbClientManager
.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), language, cancellationToken)
.ConfigureAwait(false);
var image = GetImageInfo(episodeResult.Data);
if (image != null)

View File

@ -50,7 +50,9 @@ namespace MediaBrowser.Providers.TV.TheTVDB
{
searchInfo.SeriesProviderIds.TryGetValue(MetadataProviders.Tvdb.ToString(),
out var seriesTvdbId);
episodeTvdbId = await _tvDbClientManager.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken);
episodeTvdbId = await _tvDbClientManager
.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);
if (string.IsNullOrEmpty(episodeTvdbId))
{
_logger.LogError("Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}",
@ -58,7 +60,9 @@ namespace MediaBrowser.Providers.TV.TheTVDB
return list;
}
}
var episodeResult = await _tvDbClientManager.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId), searchInfo.MetadataLanguage, cancellationToken);
var episodeResult = await _tvDbClientManager.GetEpisodesAsync(Convert.ToInt32(episodeTvdbId),
searchInfo.MetadataLanguage, cancellationToken).ConfigureAwait(false);
var metadataResult = MapEpisodeToResult(searchInfo, episodeResult.Data);
if (metadataResult.HasMetadata)
@ -104,7 +108,9 @@ namespace MediaBrowser.Providers.TV.TheTVDB
{
if (string.IsNullOrEmpty(tvdbId))
{
tvdbId = await _tvDbClientManager.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken);
tvdbId = await _tvDbClientManager
.GetEpisodeTvdbId(searchInfo, searchInfo.MetadataLanguage, cancellationToken)
.ConfigureAwait(false);
if (string.IsNullOrEmpty(tvdbId))
{
_logger.LogError("Episode {SeasonNumber}x{EpisodeNumber} not found for series {SeriesTvdbId}",
@ -115,7 +121,7 @@ namespace MediaBrowser.Providers.TV.TheTVDB
var episodeResult = await _tvDbClientManager.GetEpisodesAsync(
Convert.ToInt32(tvdbId), searchInfo.MetadataLanguage,
cancellationToken);
cancellationToken).ConfigureAwait(false);
result = MapEpisodeToResult(searchInfo, episodeResult.Data);
}

View File

@ -73,7 +73,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
};
try
{
var imageResults = await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken);
var imageResults = await _tvDbClientManager
.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken).ConfigureAwait(false);
remoteImages.AddRange(GetImages(imageResults.Data, language));
}
catch (TvDbServerException)

View File

@ -68,7 +68,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
try
{
var imageResults =
await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken);
await _tvDbClientManager.GetImagesAsync(tvdbId, imageQuery, language, cancellationToken)
.ConfigureAwait(false);
remoteImages.AddRange(GetImages(imageResults.Data, language));
}

View File

@ -84,7 +84,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
result.Item = new Series();
result.HasMetadata = true;
await FetchSeriesData(result, itemId.MetadataLanguage, itemId.ProviderIds, cancellationToken);
await FetchSeriesData(result, itemId.MetadataLanguage, itemId.ProviderIds, cancellationToken)
.ConfigureAwait(false);
}
return result;
@ -102,19 +103,23 @@ namespace MediaBrowser.Providers.TV.TheTVDB
if (seriesProviderIds.TryGetValue(MetadataProviders.Imdb.ToString(), out var imdbId) && !string.IsNullOrEmpty(imdbId))
{
series.SetProviderId(MetadataProviders.Imdb, imdbId);
tvdbId = await GetSeriesByRemoteId(imdbId, MetadataProviders.Imdb.ToString(), metadataLanguage, cancellationToken);
tvdbId = await GetSeriesByRemoteId(imdbId, MetadataProviders.Imdb.ToString(), metadataLanguage,
cancellationToken).ConfigureAwait(false);
}
if (seriesProviderIds.TryGetValue(MetadataProviders.Zap2It.ToString(), out var zap2It) && !string.IsNullOrEmpty(zap2It))
{
series.SetProviderId(MetadataProviders.Zap2It, zap2It);
tvdbId = await GetSeriesByRemoteId(zap2It, MetadataProviders.Zap2It.ToString(), metadataLanguage, cancellationToken);
tvdbId = await GetSeriesByRemoteId(zap2It, MetadataProviders.Zap2It.ToString(), metadataLanguage,
cancellationToken).ConfigureAwait(false);
}
try
{
var seriesResult =
await _tvDbClientManager.GetSeriesByIdAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken);
await _tvDbClientManager
.GetSeriesByIdAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken)
.ConfigureAwait(false);
MapSeriesToResult(result, seriesResult.Data, metadataLanguage);
}
catch (TvDbServerException e)
@ -129,7 +134,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
try
{
var actorsResult = await _tvDbClientManager.GetActorsAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken);
var actorsResult = await _tvDbClientManager
.GetActorsAsync(Convert.ToInt32(tvdbId), metadataLanguage, cancellationToken).ConfigureAwait(false);
MapActorsToResult(result, actorsResult.Data);
}
catch (TvDbServerException e)
@ -146,11 +152,13 @@ namespace MediaBrowser.Providers.TV.TheTVDB
{
if (string.Equals(idType, MetadataProviders.Zap2It.ToString(), StringComparison.OrdinalIgnoreCase))
{
result = await _tvDbClientManager.GetSeriesByZap2ItIdAsync(id, language, cancellationToken);
result = await _tvDbClientManager.GetSeriesByZap2ItIdAsync(id, language, cancellationToken)
.ConfigureAwait(false);
}
else
{
result = await _tvDbClientManager.GetSeriesByImdbIdAsync(id, language, cancellationToken);
result = await _tvDbClientManager.GetSeriesByImdbIdAsync(id, language, cancellationToken)
.ConfigureAwait(false);
}
}
catch (TvDbServerException e)
@ -210,7 +218,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
TvDbResponse<SeriesSearchResult[]> result;
try
{
result = await _tvDbClientManager.GetSeriesByNameAsync(comparableName, language, cancellationToken);
result = await _tvDbClientManager.GetSeriesByNameAsync(comparableName, language, cancellationToken)
.ConfigureAwait(false);
}
catch (TvDbServerException e)
{
@ -238,7 +247,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
try
{
var seriesSesult =
await _tvDbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, language, cancellationToken);
await _tvDbClientManager.GetSeriesByIdAsync(seriesSearchResult.Id, language, cancellationToken)
.ConfigureAwait(false);
remoteSearchResult.SetProviderId(MetadataProviders.Imdb, seriesSesult.Data.ImdbId);
remoteSearchResult.SetProviderId(MetadataProviders.Zap2It, seriesSesult.Data.Zap2itId);
}
@ -403,7 +413,8 @@ namespace MediaBrowser.Providers.TV.TheTVDB
return;
}
var srch = await FindSeries(info.Name, info.Year, info.MetadataLanguage, CancellationToken.None).ConfigureAwait(false);
var srch = await FindSeries(info.Name, info.Year, info.MetadataLanguage, CancellationToken.None)
.ConfigureAwait(false);
var entry = srch.FirstOrDefault();