Skip to content

Make ThreadingUtilities.ExecuteTasksOnNewThreads await on the operations completion. #1275

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

sanych-sun
Copy link
Member

Test console before the fix:
1 - sync method works as expected.
2 - async method "exit" before inner operations are completed.
image
image

Test console after the fix:
both sync and async methods work as expected:
image
image

@sanych-sun sanych-sun requested a review from a team as a code owner February 27, 2024 19:33
@sanych-sun sanych-sun requested review from rstam and removed request for a team February 27, 2024 19:33
@@ -110,7 +110,7 @@ public static async Task<Exception[]> ExecuteTasksOnNewThreadsCollectExceptions(
}
});

var taskAll = Task.WhenAll(allTasks);
var taskAll = Task.WhenAll(allTasks.Select(t => t.Result));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the best way to fix the problem, but this is the simplest way I could find.

@sanych-sun sanych-sun requested review from BorisDog and removed request for rstam February 27, 2024 19:59
Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sanych-sun sanych-sun force-pushed the ExecuteTasksOnNewThreads-fix branch from c1c9948 to f74d209 Compare February 28, 2024 23:17
@sanych-sun sanych-sun merged commit a90f0ab into mongodb:master Feb 28, 2024
@sanych-sun sanych-sun deleted the ExecuteTasksOnNewThreads-fix branch February 28, 2024 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants