Alternatives for a survey?
I have an asp.net C # desktop application that checks the database data every 5 minutes. This leads to a large amount of load on the server, which in turn reduces its efficiency.
Is there any technology in asp.net that supports publishing the subscription model regardless of the database used? I know that long-term polling is one of the alternatives. But I was looking for something that is event driven, not long data polling. Any help would be appreciated.
source to share
If you are actually using ASP.net, you can add a SignalR framework to set up a push channel to your desktop app.
On the server side add the nupet package Microsoft.AspNet.SignalR ( Install-Package Microsoft.AspNet.SignalR
); on the client add Microsoft.AspNet.SignalR.Client ( Install-Package Microsoft.AspNet.SignalR.Client
).
This way you can notify all your clients whenever a database update has been made, for example:
public void AddCustomer(Customer customer)
{
using (var db = new CustomerContext)
{
db.Customers.Add(customer);
db.SaveChanges();
}
var hub = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
hub(customer.Id);
}
source to share
I think you are looking for something like reactive extensions.
http://msdn.microsoft.com/en-gb/data/gg577610.aspx
Under the covers, everything is done with some polling implementation, but the idea is to get the event loop to control the poll as efficiently as possible.
source to share
I have no idea what or how much data you mean here, so this answer might be too much work if you don't have a small enough number of data tables / databases you want to look at.
Instead of pulling datasets every 5 minutes, add a table with one datetime field to your database. Then create triggers on the tables that you want to control (on add / edit / delete / whatever). Keep this in mind, when the trigger fires, it updates the date and time in the generated table.
Change your desktop app to only pull this datetime value every 5 minutes, store the cached value somewhere and compare it on every poll if the lifetime changes; your desktop application can then perform the required data refresh.
source to share