From 6b6a943294013aa2df2181ad95153dbf3e90bcbb Mon Sep 17 00:00:00 2001 From: Vincent Cloutier Date: Wed, 28 Dec 2022 10:59:15 -0500 Subject: [PATCH] made RetrieveFollowersProcessor more parallel --- .../Processors/RetrieveFollowersProcessor.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs b/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs index 57e3e49..a34adfb 100644 --- a/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs +++ b/src/BirdsiteLive.Pipeline/Processors/RetrieveFollowersProcessor.cs @@ -20,12 +20,17 @@ namespace BirdsiteLive.Pipeline.Processors public async Task> ProcessAsync(UserWithDataToSync[] userWithTweetsToSyncs, CancellationToken ct) { - //TODO multithread this + List todo = new List(); foreach (var user in userWithTweetsToSyncs) { - var followers = await _followersDal.GetFollowersAsync(user.User.Id); - user.Followers = followers; + var t = Task.Run( + async() => { + var followers = await _followersDal.GetFollowersAsync(user.User.Id); + user.Followers = followers; + }); + todo.Add(t); } + await Task.WhenAll(todo); return userWithTweetsToSyncs; }