AdReportService.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using DW5S.DTO;
  2. namespace AdService.Service
  3. {
  4. /// <summary>
  5. /// 服务上报服务(3s)
  6. /// </summary>
  7. public class AdReportService : BackgroundService
  8. {
  9. /// <summary>
  10. /// 服务上报服务
  11. /// </summary>
  12. protected override async Task ExecuteAsync(CancellationToken stoppingToken)
  13. {
  14. await Task.Run(async () =>
  15. {
  16. while (!stoppingToken.IsCancellationRequested)
  17. {
  18. SvrStateReportDto dto = new SvrStateReportDto()
  19. {
  20. DD = TimeSpan.FromSeconds(1),
  21. SvrType = EnumSvrType.AdCgSvr,
  22. SvrID = "AdService",
  23. BaseHttpAddr = "",
  24. SwaggerAddr="",
  25. ReportType = 0,
  26. };
  27. var res = await HttpHelper.PostRequestAsync<CpuCgResDto>("" + "SvrReport/Report", dto);
  28. await Task.Delay(3 * 1000, stoppingToken);
  29. }
  30. }, stoppingToken);
  31. }
  32. }
  33. }