title: SignalR Core how to send message to clients every n seconds
body: <h3>AKA "Send messages to clients from a background service"</h3>
  
  <p>I would like my SignalR server to update a dashboard every n seconds. I'm using this right now:</p>
  
  <pre><code>public class MyHub : Hub
  {
      public override Task OnConnectedAsync()
      {
          Observable.Interval(TimeSpan.FromSeconds(0.5)).Subscribe(l =&gt;
          {
              var alt = CalcAltitude(l);
              SendMessage(alt);
          });
  
          return Task.CompletedTask;
      }
  
      private void SendMessage(double alt)
      {
          Clients.All.SendAsync("SendAction", new Status() {Altitude = alt});
      }
  
      private double CalcAltitude(long l)
      {
          return 100 * Math.Sin((double) l / 100) + 200;
      }
  }
  
  public class Status
  {
      public double Altitude { get; set; }
  }
  </code></pre>
  
  <p>When my code is executed, it throws an exception saying that </p>
  
  <blockquote>
    <p>cannot access a disposed object</p>
  </blockquote>
  
  <p>I suspect I'm doing something wrong here.</p>
  
  <p>So, what's the correct way to make send messages to all the clients on a timely manner?</p>