So I’m learning SignalR, and I like the idea of pushing changes to multiple clients. I’m building a simple monitoring site to learn with, and would like to poll a database every 10 seconds or so and push the current state of what I’m querying down to the clients. Using a timer for the “hub” object results in every client connection creating a new timer, which means that eventually all clients have their own 10-second timer, and the hub is constantly pushing down updates much more often than every 10 seconds.
I’ve been pushing around different ideas in my head, but wanted to make sure this isn’t a simpler problem to fix than I’m making it out to be, either through SignalR or the more general problem of having one timer for the appdomain.
Have you tried having the timer be static, or outside the hub? You can call back into the hub like so:
More information on this can be found at https://github.com/SignalR/SignalR/wiki/Hubs towards the bottom of the page.
Basically you are having the Hub, which is per request, trying to handle something that is more global.