如何使用SignalR进行自动刷新的数据一样 [英] How to use SignalR for autorefresh like data

查看:515
本文介绍了如何使用SignalR进行自动刷新的数据一样的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找到使用 SignalR 有一段时间了,我想我有这方面的很好的候选人。

I've been looking into using SignalR for a while now, and I think I have a good candidate for it.

我有一个页面,它允许用户对系统离开注释,并在它使用的那一刻 JQuery的定期刷新的评论列表。我觉得 SignalR 将很好地取代这一点,也就是说,如果有两个用户在看列表和一个写了一个评论,我想它在第二个瞬间出现。

I have a page which allows users of the system to leave Comments, and at the moment it uses JQuery to periodically refresh the list of comments. I think SignalR would replace this nicely, i.e. if there were two users looking at the list and one wrote a comment, I would like it to appear instantly in the second.

都很好,我有一个的排序的模板在那里工作的。

All well and good, I have a sort of template where this works.

然而

我的系统本身有时可以添加自动通知到列表 - 这些是直接通过非基于web的应用投入数据库

My system itself can sometimes add automatic notifications to the list - These are put into the database directly by a non-web based application.

我如何获得 SignalR 来从数据库中看到了新的信息,并将其发送给用户?

How can I get SignalR to see the new information from the database and send it to the users?

推荐答案

SignalR 中的枢纽是在应用程序中的静态部分。您可以旋转起来在<一个href=\"http://stackoverflow.com/questions/1416803/system-timers-timer-vs-system-threading-timer\">System.Threading.Timer在你的web应用,定期检查你的数据库的新通知,并添加那些由中心所使用的数据

In SignalR the hub is a static part in your application. You can spin up a System.Threading.Timer in your webapplication to periodically check your database for new notifications and add those to the data used by the hub.

这甚至可以通过使用<一个得到改善href=\"http://stackoverflow.com/questions/642848/performance-questions-for-sql-cache-dependency\">SqlCacheDependency.

一个主观侧​​面说明:我不同意这种类型的功能是一个很好的候选人 SignalR

A subjective side note: I do agree this type of functionality is a very good candidate for SignalR.

这篇关于如何使用SignalR进行自动刷新的数据一样的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆