Question

I want to use SignalR in my MVC app. The method shoud be like that: There will be some method which runs all the time in background, and checks if there is new row in database table. If there is, it will invoke a method which will broadcast the new row and send to the client view.

How can I do that (I guess I need a method that runs all the time in tha background)? Thanks!

No correct solution

OTHER TIPS

Hmm...

If you want something that is running all the time, you could do it with a service, or with a background thread as Rafa suggests - but before you do either I would have a look at whether your overall design could be improved. Polling the database all the time looking for a new row will mean a lot of unnecessary database traffic...

What's adding the row in the first place? Could we get that code to raise some form of event / invoke an action for us? Depending on the database, are row level triggers available to us? Can we use that to avoid polling?

I don't think you should be actually typing code yet, but rather challenging your current design to see how you might improve it...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top