4

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.

asked Nov 20, 2011 at 17:16
4
  • What have you thought to try? AJAX timer? Some other timing mechanism? Commented Nov 20, 2011 at 19:27
  • 1
    WebSockets of Server Sent events are your friends for real time Commented Nov 21, 2011 at 1:03
  • AJAX? WebSockets? The question specifies Silverlight... Commented Nov 21, 2011 at 13:11
  • Define "real time" before proceeding. Commented Jan 20, 2012 at 1:57

3 Answers 3

1

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.

answered Nov 21, 2011 at 0:23
1

Hmmm,

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?
answered Apr 12, 2012 at 15:16
0

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.

answered Nov 20, 2011 at 20:05
1
  • 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. Commented Jan 7, 2012 at 16:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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