user999690
user999690

Reputation: 267

How to snyc data refresh between C# apps at the same time

I have a C# program that calls a SQL database. I want to duplicate this program 10 times and have all programs call the SQL database at the same time. How would this be done?

I am pulling data on a timer/loop. For example, if program A is executed before program B, the refresh times will differ. Is there a way to sync this refresh?

Upvotes: 1

Views: 410

Answers (2)

Simon Edström
Simon Edström

Reputation: 6619

I think maybe the simplest solution is to just make the calls to the DB at every full minute. All the clients have the same Time servers, so there clock should be in sync?

Or you can have a server application that all the clients connect to thru socket, or pulling data thru a simple HTTP request. When they get the "update command" they simply query the database.

Or you make a server application that querys the database and cache the data. And the clients only query the cache. Simple to implement with WCF

Upvotes: 1

Erre Efe
Erre Efe

Reputation: 15577

You'll need to have a man in the middle. I mean, you need to provide a service between your desktop clients and the DB. That service will contain the update timer.

Now, every X seconds you ping that service to seek if the update time has changed. And every time that a client call for data, well, you update the timer on the service. So suppose there rest 3 minutes to update, every client knows that, but then your program A does something that alter that timer, well then, when others ping the service will note that and change it's internal update timers also.

Upvotes: 3

Related Questions