문제

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!

올바른 솔루션이 없습니다

다른 팁

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...

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top