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. Multiple Timers

Multiple Timers

Scheduled Pinned Locked Moved C#
helpquestioncsharpsysadmindata-structures
4 Posts 2 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.
  • P Offline
    P Offline
    push1988
    wrote on last edited by
    #1

    Hello everyone, I am a beginner at C#. My problem is as follows: 1. I am coding a server app running on a single proxy server. 2. We have got a client app on each client machine which pings the server (using UDP) 3. For the first ping, server app creates a new entry in the existing linked list (using IPAdress) 4. For each such entry, it starts a timer (should run for 60 sec.) 5. If any client app pings again within 60 secs, its timer should be reset. Timer Code should be non blocking. 6. If timer expires, corrosponding IPAddress Node should be removed from Linked List. How do I implement this specific timer functionality? I will have to start 100 timers for 100 clients! And that too, each timer should have its own identity... IPAdress! :omg: Please help. Waiting anxiously for reply. Thank you. :^)

    P 1 Reply Last reply
    0
    • P push1988

      Hello everyone, I am a beginner at C#. My problem is as follows: 1. I am coding a server app running on a single proxy server. 2. We have got a client app on each client machine which pings the server (using UDP) 3. For the first ping, server app creates a new entry in the existing linked list (using IPAdress) 4. For each such entry, it starts a timer (should run for 60 sec.) 5. If any client app pings again within 60 secs, its timer should be reset. Timer Code should be non blocking. 6. If timer expires, corrosponding IPAddress Node should be removed from Linked List. How do I implement this specific timer functionality? I will have to start 100 timers for 100 clients! And that too, each timer should have its own identity... IPAdress! :omg: Please help. Waiting anxiously for reply. Thank you. :^)

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I wouldn't. I would prefer a database, but a Dictionary would work too. On each ping, I'd update the database or Dictionary for the pinger with the current time. Then periodically, enumerate the list, removing any entries where the time is expired.

      P 1 Reply Last reply
      0
      • P PIEBALDconsult

        I wouldn't. I would prefer a database, but a Dictionary would work too. On each ping, I'd update the database or Dictionary for the pinger with the current time. Then periodically, enumerate the list, removing any entries where the time is expired.

        P Offline
        P Offline
        push1988
        wrote on last edited by
        #3

        But if I use a dictionary/database, how do I decrement the timer for each entry after each second? Since, in general, the number of entries may be large, how do I ensure that the decrement of the first entry and the last entry takes place within that same second? :(

        P 1 Reply Last reply
        0
        • P push1988

          But if I use a dictionary/database, how do I decrement the timer for each entry after each second? Since, in general, the number of entries may be large, how do I ensure that the decrement of the first entry and the last entry takes place within that same second? :(

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          You don't, you simply compare the time of the last ping with the current time and remove any entries that are older than some threshold.

          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