We would want to send timely emails to subscribers about updates/changes to the database. What would be an optimum approach to this. Is considering SignalR a good path?

Example: Let us say we have a list of phones with specific features in the database. User wants to get notified whenever a new phone with front camera of 8 Mega pixels comes into market.

Considered storing email subscribers, and their conditions, check database every night, and send emails.

Read about SignalR and real time updates but could not wrap my head over its applications. Can it be applied to scenario that I have mentioned?

  • Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    Oct 8, 2014 at 8:30

1 Answer 1


Sending emails to subscribers every once in a while isn't really a real-time requirement. Subscribers would read your emails after a few minutes at the very least, so why bother sending them within microseconds of updates.

It would be best suited for a scheduled task that runs in set intervals like 60 seconds.

Here's a simple task scheduling technique that StackOverflow itself used in its early days:

  1. At startup, add an item to the HttpRuntime.Cache with a fixed expiration.
  2. When cache item expires, do your work (send your emails)
  3. Re-add the item to the cache with a fixed expiration.

This goes into Global.asax:

private static CacheItemRemovedCallback OnCacheRemove = null;

protected void Application_Start(object sender, EventArgs e)
    AddTask("DoStuff", 60);

private void AddTask(string name, int seconds)
    OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
    HttpRuntime.Cache.Insert(name, seconds, null, 
        DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
        CacheItemPriority.NotRemovable, OnCacheRemove);

public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
    // do stuff here if it matches our taskname, like WebRequest
    // re-add our task so it recurs
    AddTask(k, Convert.ToInt32(v));

Source: http://blog.stackoverflow.com/2008/07/easy-background-tasks-in-aspnet/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.