title: How to use SignalR to notify web clients from ASP.NET MVC 3 that MSMQ tasks were completed
body: <p>How would one use SignalR to implement notifications in an .NET 4.0 system that consists of an ASP.NET MVC 3 application (which uses forms authentication), SQL Server 2008 database and an MSMQ WCF service (hosted in WAS) to process data? The runtime environment consists of IIS 7.5 running on Windows Server 2008 R2 Standard Edition. </p>
  
  <p>I have only played with the samples and do not have extensive knowledge of SignalR.</p>
  
  <p><strong>Here is some background</strong></p>
  
  <p>The web application accepts data from the user and adds it to a table. It then calls an one way operation (with the database key) of the WCF service to process the data (a task). The web application returns to a page telling the user the data was submitted and they will be notified when processing is done. The user can look at an "index" page an see which tasks are  completed, failed or are in progress. They can continue to submit more tasks (which is independent of previous data). They can close their browser and come back later.</p>
  
  <p>The MSMQ based WCF service reads the record from the database and processes the data. This may take anything from milliseconds to several minutes.  When its done processing the data, the record is updated with the corresponding status (error or fail) and results.</p>
  
  <p>Most of the time, the WCF service is not performing any processing, however when it does, users generally want to know when its done as soon as possible. The user will still use other parts of the web application even if they don't have data to be processed by the WCF Service.</p>
  
  <p><strong>This is what I have done</strong></p>
  
  <p>In the primary navigation bar, I have an indicator (similar to Facebook or Google+) for the user to notify them when the status of tasks has changed.  When they click on it, they get a summary of what was done and can then view the results if they wish to.</p>
  
  <p>Using jQuery, I poll the server for changes. The controller action checks to see if there is any processes that were modified (completed or failed) and return them otherwise waits a couple of seconds and check again without returning to the client. In order to avoid a time out on the client, it will return after 30 seconds if there was no changes. The jQuery script waits a while and tries again. </p>
  
  <p><strong>The problems</strong></p>
  
  <p>Performance degrades with every user that views a page. There is no need for them to do anything in particular. We've noticed that memory usage of Firefox 7+ and Safari increases over time.</p>
  
  <p><strong>Using SignalR</strong></p>
  
  <p>I'm hoping that switching to SignalR can reduce polling and thus reduce resource requirements especially if nothing has changed task wise in the database. I have trouble getting the WCF service to notify clients that its done with processing a task given the fact that it uses forms based authentication. </p>
  
  <p>By asking this question, I hope someone will give me better insight how they will redesign my notification scheme using SignalR, if at all.</p>