Take the 2-minute tour ×

Currently I have a WCF method which brings back all the data from the db and binds it to a grid, but I would like to call this method regularly to get the updated data back each time, to show the user real time data, what is the best way to go about this?

Thanks in advance.

share|improve this question

migrated from stackoverflow.com Nov 20 '11 at 20:18

This question came from our site for professional and enthusiast programmers.

What have you thought to try? AJAX timer? Some other timing mechanism? –  sq33G Nov 20 '11 at 19:27
WebSockets of Server Sent events are your friends for real time –  Raynos Nov 21 '11 at 1:03
AJAX? WebSockets? The question specifies Silverlight... –  Nicholas W Nov 21 '11 at 13:11
Define "real time" before proceeding. –  Wyatt Barnett Jan 20 '12 at 1:57

3 Answers 3

Check parapura's answer in this Question.
This approach is called long polling, its simple and should provide you the data you want whenever its available from the server side.
Check this Blog for more detailed sample class.

share|improve this answer


I do not know what your application function is, but could you try something like this?

  • What puts the data in your db constantly? Why not just give that to your grid ( might need a bit of formatting and data hiding of course / or store data at application level up to certain limit ) That way you are absolute real time.

Now, to update db why not make a db update when a grid add 10 rows or something from that application level storage or your data grid.

  • This makes you have less db calls , increasing latency. Also makes you real time.
  • Thoughts?
share|improve this answer

I would create a backgroundworker thread and put it into an endless loop. You could send the request to the service asynchronously if a specified period of time has elapsed (2 seconds maybe?) and you are not still waiting on results from the previous request. When the completion event fires, update your UI.

Having said that, if there is a lot of data involved, I would find out if there was a way in which you could only retrieve the differences between the last data that you received and the current data (i.e. adds, updates, deletes) and only make those changes to the grid data rather than rebinding every time.

share|improve this answer
You could also use two-way WCF binding and let the server push updates to the client. Depending what constitutes as an update (and if the server itself would be aware) it may be better suited since you'll only get updates when they're necessary. –  Brad Christie Jan 7 '12 at 16:13

Your Answer

