diff --git a/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md b/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md index 5bf893bf1b..b69d14e1a8 100644 --- a/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md +++ b/docs/en/Community-Articles/2026-03-23-Dynamic-Events-in-ABP/POST.md @@ -120,13 +120,16 @@ public class PartnerOrderHandler : IDistributedEventHandler - **`EventName`** — the string name that identifies the event - **`Data`** — the raw event data payload (the deserialized `object` from the broker) -> `Subscribe` returns an `IDisposable`. Call `Dispose()` to unsubscribe the handler at runtime. For application-lifetime subscriptions, prefer module initialization (`OnApplicationInitializationAsync`) over subscribing inside an application service. +> `Subscribe` returns an `IDisposable`. Call `Dispose()` to unsubscribe the handler at runtime. For application-lifetime subscriptions, prefer module initialization (`OnApplicationInitialization` / `OnApplicationInitializationAsync`) over subscribing inside an application service. ## Mixed Typed and Dynamic Handlers Typed and dynamic handlers coexist naturally. When both are registered for the same event name, **both are triggered** — the framework automatically converts the data to the appropriate format for each handler. ```csharp +var eventBus = context.ServiceProvider.GetRequiredService(); +var scopeFactory = context.ServiceProvider.GetRequiredService(); + // Typed handler — receives OrderPlacedEto eventBus.Subscribe(); diff --git a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs index 173d5a8531..efecb25b2b 100644 --- a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs +++ b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs @@ -384,7 +384,7 @@ public class LocalDistributedEventBus_Test : LocalDistributedEventBusTestBase services.AddSingleton( new TestCounterService(() => handleCount++, () => disposeCount++)); services.AddTransient(); - var provider = services.BuildServiceProvider(); + using var provider = services.BuildServiceProvider(); var scopeFactory = provider.GetRequiredService(); using var subscription = DistributedEventBus.Subscribe( @@ -410,7 +410,7 @@ public class LocalDistributedEventBus_Test : LocalDistributedEventBusTestBase var services = new ServiceCollection(); services.AddSingleton(new TestCounterService(() => callCount++)); services.AddTransient(); - var provider = services.BuildServiceProvider(); + using var provider = services.BuildServiceProvider(); var scopeFactory = provider.GetRequiredService(); using var subscription = DistributedEventBus.Subscribe(