Skip to content

Commit

Permalink
Merge branch 'master' of github.com:poma/HotsStats
Browse files Browse the repository at this point in the history
  • Loading branch information
poma committed Oct 18, 2016
2 parents a8a2fe7 + 6e42379 commit 8586a59
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions StatsFetcher/ProfileFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,26 @@ namespace StatsFetcher
{
public class ProfileFetcher
{
private Game game;
private HttpClient web;
private readonly Game game;
private readonly HttpClient web = new HttpClient();

public ProfileFetcher(Game game)
{
this.game = game;
this.web = new HttpClient();
}

public async Task FetchBasicProfiles()
{
var tasks = new List<Task>();

// start all requests in parallel
foreach (var p in game.Players) {
tasks.Add(FetchBasicProfile(p));
}

foreach (var task in tasks) {
await task;
}
await Task.WhenAll(game.Players.Select(FetchBasicProfile)).ConfigureAwait(false);
}

public async Task FetchFullProfiles()
{
var tasks = new List<Task>();

// start all requests in parallel
foreach (var p in game.Players) {
tasks.Add(FetchFullProfile(p));
}

foreach (var task in tasks) {
await task;
}
await Task.WhenAll(game.Players.Select(FetchFullProfile)).ConfigureAwait(false);
}

private async Task FetchBasicProfile(PlayerProfile p)
Expand Down

0 comments on commit 8586a59

Please sign in to comment.