Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. internal class TimedHostedService : IHostedService, IDisposable
  2. {
  3. public TimedHostedService(IServiceProvider services)
  4. {
  5. }
  6.  
  7. private async Task Test()
  8. {
  9. using (var scope = _services.CreateScope())
  10. {
  11. var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
  12. await mediator.Send(new Application.Test.Command());
  13. }
  14. }
  15. }
  16.  
  17. internal class TimedHostedService : IHostedService, IDisposable
  18. {
  19. ...
  20.  
  21. public TimedHostedService(IServiceScopeFactory scopeFactory)
  22. {
  23. }
  24.  
  25. private async Task Test()
  26. {
  27. using (var scope = _scopeFactory.CreateScope())
  28. {
  29. var mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
  30. await mediator.Send(new Application.Test.Command());
  31. }
  32. }
  33.  
  34. ...
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement