2

I am using VS2010 - C# - WPF I have a desktop application that I built, and this application shows some values. these values are brought from a web page that I made too.

Now everytime I change the values on the webpage the values must be changed on the applications.

But I don't want the applications to keep refreshing because the refresh rate is low, so I want the webpage to notigy all apps. on a button click from the website.

is such thing possible ? knowing that anyone can download the application but no one can access the website but me ?

Teoman Soygul
  • 25,584
  • 6
  • 69
  • 80

2 Answers2

2

I will consider your problem as an academical one of "How to get the server to push notification to the client" and answer, but I think the better, and more common solution is for the client application to do polling on a server endpoint, and update itself, as Tejs says.

As for the question, You have to

  1. Make your application listen to HTTP connections on a free port.
  2. Send a message to the server that you are listening on Port X for http connections. This is like a registration, that registers your client to the server.
  3. On the server side build an endpoint where clients can register, and maintain a list of registered clients to be notified.
  4. When notification needs to happen, use the list to connect to and push notification to the clients.

Top issues you will face are, problems like what to do if client does not respond, how to maintain the list - in-memory or in-DB and so on.

Zasz
  • 12,330
  • 9
  • 43
  • 63
  • Your solution looks promising but having never done anything close to that I'm having problems implementing it, any idea where to start? Or an example perhaps? – Nikhil Girraj Mar 26 '13 at 09:14
  • Or [WCF Callbacks](http://idunno.org/archive/2008/05/29/wcf-callbacks-a-beginners-guide.aspx) if you are using desktop clients. The webserver can expose a wcf service, which is used by the client, to register itself, and to listen for notifications. Or you can build a system purely with HTTP requests - [This](https://github.com/chandru9279/StarBase/blob/9397bb2fe22b75554775d706e19a94551e5f5221/Projects/GAServer/GAServer/ServingThread.cs) has some code that can be used on the server-side, but the purpose of the code is different (Its a p2p POC). – Zasz Mar 26 '13 at 10:17
0

There's not going to be any kind of magic here; it depends on your update interval. If you want them to just get the freshest value on the applications first start, then you can simply make the web request in the application load method. Otherwise, you will need to implement some kind of polling for updates in your application, just on a long interval (say 2 hours between each request, etc).

Tejs
  • 40,736
  • 10
  • 68
  • 86
  • actually I thought about your solution but the problem is that my application withdraws currency exchange prices and such values could stay the same for a whole day or change for a couple of times in an hour – mouayad al zein May 19 '11 at 14:28