Skip to content

Add "UseTaskWhenAll" option#20

Merged
KuraiAndras merged 7 commits intoKuraiAndras:masterfrom
fretje:parallel
Jun 16, 2025
Merged

Add "UseTaskWhenAll" option#20
KuraiAndras merged 7 commits intoKuraiAndras:masterfrom
fretje:parallel

Conversation

@fretje
Copy link
Contributor

@fretje fretje commented Jun 11, 2025

I am using this libaray in blazor, and due to the fact that the event handlers are run sequentially, it sometimes takes a while for components to update, because they have to wait for other components that subscribe to the same events.

I work around this now by changing most of my event handlers to void methods and use this pattern instead:

_ = InvokeAsync(async () => await ...);

But just like mediatr now has its TaskWhenAllPublisher, I thought I make something similar for Courier.

This pr is the result.

When the new option "UseTaskWhenAll" is true, all the tasks are now gathered into a list, and then awaited for at the end with Task.WhenAll, in stead of sequentially.

I have also added a couple of tests.

Let me know if the naming is ok. The option could be named something like "PublishParallel" as well?


With this I would be able to use actual async event handlers again so I don't have to resort to the "InvokeAsync pattern" I talked about above.


This is based on #19

@sonarqubecloud
Copy link

Please retry analysis of this Pull-Request directly on SonarQube Cloud

@KuraiAndras
Copy link
Owner

Please update to the latest master so I can see the changes only in this branch

@fretje
Copy link
Contributor Author

fretje commented Jun 16, 2025

Wait for the merge, I'm adding some info to the readme as well...

@KuraiAndras KuraiAndras merged commit 264932e into KuraiAndras:master Jun 16, 2025
1 check passed
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