views:

45

answers:

1

I need to synchronize the data that "one client" updated and need to be refreshed on "other client" (on another room) of the same application.

1 - Which is the best approach to doing this? I was thinking on SqlDependency but the application can also run on other database engines (I dismiss it) I also think of a timer polling for updates, but I really don´t want to check for a change periodically.

Does anybody has this problem? How did you solve it?.

2 - Additionally. When the data must be updated in the UI without obstruct the work ofo the people in the other pc?

Scenario: 3 PC working with the same data. Creating / updating records that need to be synchronized (to get the last changes that every PC made).

I hope I was clear about my situation.

Thank in advance.

A: 

If you know that you are only gonna have 2 instances of the application, then you could do it with WCF. Each of the clients acts as a server for the other one when they want to send an update.

How you want to handle updates to data being edited by both clients... that can be tricky. It depends on your type of data, if the GUI is developed to handle updates and such things.

Paw Baltzersen
Sorry, but I think you don´t understand me completely. I have the same application in several computers. Working in the same app I want that if operator1 change "the name of a user" the change will be reflected on the application that operator2 and operator3 is working. I need to synchronize the changes made in one computer to the others.
Andres
It's the same as cross-thread communication, like "gui with worker thread". You have either "server informs client" or "client pools server". If you don't want to pool server, use remoting/wcf/sockets to inform clients. And anyway, you will need to provide some kind of lock (optimistic or pessimistic) on you data. Event-based synchronization is not enough to maintain integrity of your data.
Dmitry Karpezo
So you are proposing a model where the communication to inform the changed data (in PC1) that need to change/refresh the updated data on PC2, PC3 and "other" will be using a socket. My 3 choices are: 1 - Sockets between the clientes as you said (may be I will aggregate a mini server that does broadcast to the other clients, just an idea), 2 - using sqldependency or something like that, 3 - polling periodically using a timer (bad choice)...
Andres
I would try to solve this with a client/server solution, where the server distributes updates to connected clients. This way, you can also implement locks on objects that are being edited, if this will solve the edit/update issues. Client1 starts editing an objects, communicates this to the server, the server creates a lock for this object (with a key and a timeout), the server communicates this to all connected clients. This is one way of doing it. The client can also ask the server for an object's lock, and the server then desides if the client can have it or not.
Paw Baltzersen