title: Calling SignalR service from a BackgroundWorker in ABP
body: <p>I have a BackgroundWorker which is supposed to broadcast something to all online clients in 5 seconds interval:</p>
  
  <p><strong>DeactivationBackgroundWorker:</strong></p>
  
  <pre><code>public class DeactivationBackgroundWorker : PeriodicBackgroundWorkerBase, ISingletonDependency
  {
      private readonly IRepository&lt;HitchRequest, long&gt; _hitchRequestRepository;
      private readonly IHitchHub _hitchHub;
  
      public DeactivationBackgroundWorker(AbpTimer timer,
                                          IRepository&lt;HitchRequest, long&gt; hitchRequestRepository,
                                          IHitchHub hitchHub) : base(timer)
      {
          _hitchRequestRepository = hitchRequestRepository;
          Timer.Period = 5000;
          _hitchHub = hitchHub;
      }
  
      protected override async void DoWork()
      {
          await broadcastHitchRequestsAsync();
      }
  
      [UnitOfWork]
      private async Task broadcastHitchRequestsAsync() {
          var activeHitchRequests = _hitchRequestRepository.GetAllList(p =&gt; p.IsActive);
  
          foreach (var hitchRequest in activeHitchRequests)
          {
              await _hitchHub.RequestHitch(hitchRequest.Id);
          }
  
      }
  }
  </code></pre>
  
  <p><strong>IHitchHub:</strong></p>
  
  <pre><code>public interface IHitchHub: ITransientDependency
  {
      Task RequestHitch(long hitchId);
  }
  </code></pre>
  
  <p><strong>HitchHub:</strong></p>
  
  <pre><code>public class HitchHub : AbpCommonHub, IHitchHub
  {
      private readonly IOnlineClientManager _onlineClientManager;
  
      public HitchHub(IOnlineClientManager onlineClientManager, IClientInfoProvider clientInfoProvider): base(onlineClientManager, clientInfoProvider)
      {
          _onlineClientManager = onlineClientManager;
      }
  
      public async Task RequestHitch(long hitchId)
      {
          var onlineClients = _onlineClientManager.GetAllClients();
          foreach (var onlineClient in onlineClients) {
  
              var signalRClient = Clients.Client(onlineClient.ConnectionId);
  
              await signalRClient.SendAsync("receiveHitch", hitchId);
          }
      }
  }
  </code></pre>
  
  <p>I do not know why the <strong>Clients</strong> in the HitchHub class is always null! Where should I initialize it?</p>