Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. GUI and database synchronization

GUI and database synchronization

Scheduled Pinned Locked Moved C#
databasehelptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    leone
    wrote on last edited by
    #1

    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.

    L N 2 Replies Last reply
    0
    • L leone

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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[^]

      L 1 Reply Last reply
      0
      • L Lost User

        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[^]

        L Offline
        L Offline
        leone
        wrote on last edited by
        #3

        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.

        L 1 Reply Last reply
        0
        • L leone

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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[^]

          1 Reply Last reply
          0
          • L leone

            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.

            N Offline
            N Offline
            Nicolas Marzoni
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups