Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- internal class TimedHostedService : IHostedService, IDisposable
- {
- public TimedHostedService(IServiceProvider services)
- {
- }
- private async Task Test()
- {
- using (var scope = _services.CreateScope())
- {
- var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
- await mediator.Send(new Application.Test.Command());
- }
- }
- }
- internal class TimedHostedService : IHostedService, IDisposable
- {
- ...
- public TimedHostedService(IServiceScopeFactory scopeFactory)
- {
- }
- private async Task Test()
- {
- using (var scope = _scopeFactory.CreateScope())
- {
- var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
- await mediator.Send(new Application.Test.Command());
- }
- }
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement