Skip to content

Commit 5be4f8e

Browse files
committed
update readme
1 parent fb51b1b commit 5be4f8e

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,33 @@ In the same way as using MediatR can be thought of as replacing business layer s
154154
### Weak references
155155

156156
You can create a weak subscription by using the `SubscribeWeak` method. This subscription uses a `WeakReference` which will let the subscriber to be garbage collected without the need to unsubscribe (although you still can unsubscribe manually). Subscribing methods on `MonoBehavior` instances in Unity3D might result in unexpected behavior, so you should be careful with it.
157-
158-
```c#
159157
courier.SubscribeWeak<MyNotification>(notification => /*...*/);
160158

161159
courier.SubscribeWeak<MyNotification>((notification, cancellation) => /*...*/);
162-
```
163-
164160
### Capturing thread context
165161

166162
You can configure how the Courier awaits the sent notifications. To change the behavior modify the `CaptureThreadContext` property on the `CourierOptions` class. When using dependency injection, you can change this behavior during runtime, because the `CourierOptions` is accessible through DI.
167163

164+
### Parallel notification handling
165+
166+
You can configure whether notification handlers should run sequentially or in parallel by using the `UseTaskWhenAll` property on the `CourierOptions` class:
167+
168+
```c#
169+
// Configure at registration time
170+
services.AddCourier(typeof(MyType).Assembly, options =>
171+
{
172+
options.UseTaskWhenAll = true; // Enable parallel execution of handlers
173+
});
174+
175+
// Or modify at runtime through dependency injection
176+
var options = serviceProvider.GetRequiredService<CourierOptions>();
177+
options.UseTaskWhenAll = true;
178+
```
179+
180+
When `UseTaskWhenAll` is set to `true`, asynchronous notification handlers are collected and awaited concurrently using `Task.WhenAll`.
181+
182+
When set to `false` (the default), handlers are awaited sequentially.
183+
168184
## Gotchas
169185

170186
* No ordering is guaranteed when calling the subscribed methods

0 commit comments

Comments
 (0)