Multiple Timers
-
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. :^)
-
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. :^)
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.
-
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.
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? :(
-
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? :(
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.