Can anyone here tell me whether there is a way to learn that a workstation has gone to sleep, and when? Somewhere in Windows event logs?

Comments

  1. Can't you periodically check the DB connection in your app and determine if it has timed out - or lost connectivity in some other way?

    In my apps, I "ping" the DB server every few seconds and measure the turnaround time of a simple query.  I use this information to detect slow WAN connections.  I use a SELECT statement that searches for a few random records in a large table, so as not to use the server's cache.  I update another table containing a list of my active users, their ping times in milliseconds and how long my app has been idle (no keystrokes).

    My ping algorithm is also useful to check the connectivity of my app to the DB server.  If the connection goes away, my app tries to reconnect.  Upon retry-failure I light up a little red "LED" on my main form that tells the user they don't have a connection any more.

    A side effect of pinging the server is that it keeps the DB connection open - a good thing in my case as I can set the DB server session timeout to be a couple of ping intervals long.

    ReplyDelete
  2. Kevin McCoy There are several approaches I could take, but have been asked to investigate the one I described in the original question. At the moment, my best thought is to keep a local note of the login time, and when the exception fires for the lost connection, check the login time against the current time to see whether to simply report the exception, or report that the user should have logged out. The user interface approach is the real issue to be resolved.

    ReplyDelete

Post a Comment