Skip to content
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

use Task.WhenAll to await the completion of all send operations simultaneously. #8

Open
bierquelle06 opened this issue Aug 22, 2023 · 0 comments

Comments

@bierquelle06
Copy link
Member

Async Overhead in SendBatchNotificationAsync:
In the SendBatchNotificationAsync method, you are awaiting the completion of sending each notification individually. This can lead to increased overhead due to the continuous waiting for each send operation to complete.

Recommendation: If sending each notification doesn't require a dependency on the result of the previous one, consider using Task.WhenAll to await the completion of all send operations simultaneously. This can improve the efficiency of handling multiple sends concurrently.

...\src\AdsPush.Firebase\FirebasePushNotificationSender.cs

public async Task SendBatchNotificationAsync(
IEnumerable notifications,
CancellationToken cancellationToken = default)
{
var result = await this._firebaseMessaging.SendAllAsync(notifications, cancellationToken);
return new FirebaseNotificationBatchResult(result.Responses.Select(FirebaseNotificationResult.CreateUsingFirebaseSendResponse).ToList());
}

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

No branches or pull requests

1 participant