Advertisement
Guest User

Untitled

a guest
May 25th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. internal class Program
  2. {
  3. private static void Main(string[] args)
  4. {
  5. var services = new ServiceCollection();
  6.  
  7. var serviceProvider = Bootstrapper.GetServiceProvider(services);
  8.  
  9.  
  10. HostFactory.Run(configurator =>
  11. {
  12. configurator.SetServiceName("InvoiceProcessingService");
  13. configurator.SetDisplayName("InvoiceProcessingService");
  14. configurator.SetDescription("InvoiceProcessingService");
  15.  
  16. configurator.RunAsLocalSystem();
  17.  
  18. configurator.Service<InvoiceService>(serviceConfigurator =>
  19. {
  20. var jobFactory = serviceProvider.GetRequiredService<IJobFactory>();
  21.  
  22. serviceConfigurator.ConstructUsing(() => new InvoiceService(jobFactory));
  23.  
  24. serviceConfigurator.WhenStarted((service, hostControl) =>
  25. {
  26. service.OnStart();
  27. return true;
  28. });
  29. serviceConfigurator.WhenStopped((service, hostControl) =>
  30. {
  31. service.OnStop();
  32. return true;
  33. });
  34. });
  35. });
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement