GUI and database synchronization
-
Hello. I always wonder that how to keep users' GUI updated. I mean how a software should reflect its database fast and efficiently. I generally deal with this problem using a timer checking db every 20-30 seconds but i think it slows down my programs. I would prefer it like filesystemwatcher control. It realizes all files immmediately in folders and doesnt slow down applications at all.
-
Hello. I always wonder that how to keep users' GUI updated. I mean how a software should reflect its database fast and efficiently. I generally deal with this problem using a timer checking db every 20-30 seconds but i think it slows down my programs. I would prefer it like filesystemwatcher control. It realizes all files immmediately in folders and doesnt slow down applications at all.
leone wrote:
I always wonder that how to keep users' GUI updated.
You're not the first with this idea, and there's a good reason why most applications don't behave that way.
leone wrote:
I mean how a software should reflect its database fast and efficiently.
The software never loads the entire database with the user looking at the entire database. It's always a part of the data that the user looks at, and usually they work with a snapshot - not with data that changes under their cursor.
leone wrote:
I generally deal with this problem using a timer checking db every 20-30 seconds but i think it slows down my programs.
How is it implemented? Just refetching the entire dataset? That'll not only slow down your program, it'll slow down the network. How about putting a timestamp in there that holds the last modification-datetime? You could fetch that every N seconds, and fetch the data once it changes.
leone wrote:
I would prefer it like filesystemwatcher control. It realizes all files immmediately in folders and doesnt slow down applications at all.
The FSW does slow the machine down. You could put each table in a CSV file and host them from a directory - that way you could use the FSW with your data :) OTOH, you'd lose all the benefits from having a database.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
leone wrote:
I always wonder that how to keep users' GUI updated.
You're not the first with this idea, and there's a good reason why most applications don't behave that way.
leone wrote:
I mean how a software should reflect its database fast and efficiently.
The software never loads the entire database with the user looking at the entire database. It's always a part of the data that the user looks at, and usually they work with a snapshot - not with data that changes under their cursor.
leone wrote:
I generally deal with this problem using a timer checking db every 20-30 seconds but i think it slows down my programs.
How is it implemented? Just refetching the entire dataset? That'll not only slow down your program, it'll slow down the network. How about putting a timestamp in there that holds the last modification-datetime? You could fetch that every N seconds, and fetch the data once it changes.
leone wrote:
I would prefer it like filesystemwatcher control. It realizes all files immmediately in folders and doesnt slow down applications at all.
The FSW does slow the machine down. You could put each table in a CSV file and host them from a directory - that way you could use the FSW with your data :) OTOH, you'd lose all the benefits from having a database.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
Thanks Eddy. I generally dont keep sql connection open. I open it once i need. so to do what you told me, i have to open an sql connection, read a table (modification dates table) and close it again. When i do so in every 20 seconds, i have a concern that the application will slow down. I notice that some programs that i use at work reflect changes immediately. I dont think that they check this modification table every 1 second. I am curious about this.
-
Thanks Eddy. I generally dont keep sql connection open. I open it once i need. so to do what you told me, i have to open an sql connection, read a table (modification dates table) and close it again. When i do so in every 20 seconds, i have a concern that the application will slow down. I notice that some programs that i use at work reflect changes immediately. I dont think that they check this modification table every 1 second. I am curious about this.
leone wrote:
I generally dont keep sql connection open.
Never said you did :)
leone wrote:
When i do so in every 20 seconds, i have a concern that the application will slow down.
Yes, that will slow the app, the database-server and the network.
leone wrote:
I notice that some programs that i use at work reflect changes immediately.
Not by pushing the entire database, and I doubt that the database pushes information to each connected client. You can poll as I already described, simulating the push.
leone wrote:
I dont think that they check this modification table every 1 second.
It matters little how often they check that table; it's simply more efficient than fetching an entire table.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
Hello. I always wonder that how to keep users' GUI updated. I mean how a software should reflect its database fast and efficiently. I generally deal with this problem using a timer checking db every 20-30 seconds but i think it slows down my programs. I would prefer it like filesystemwatcher control. It realizes all files immmediately in folders and doesnt slow down applications at all.
Hi leone. Some DBs, such as SqlServer, allow create files. So you could write a trigger that creates a file when a table was updated. Then with the FileSystemWatcher you can refresh the UI. I hope that helps you.