0

I have a C# Windows application that marks the user as logged in in a database when he logs in to application and marks him as logged out when he exits the application.

My problem is that my application does not mark the user as logged out in the database when the user kills the application through the task manager or when the system is restarted without logging out of the application.

Is there any way to mark the user as logged out in these two situations?

phant0m
  • 16,595
  • 5
  • 50
  • 82
  • Define `restart` - if the user shuts down windows I believe it gives applications time to close down properly, but if they hit the reset button there's nothing you can do. – Rawling May 28 '12 at 07:40
  • 2
    This SO question should be helpful: http://stackoverflow.com/questions/838261/handling-end-process-of-a-windows-app – Ian Gilroy May 28 '12 at 07:44
  • 2
    What about other failures, like power loss, or hitting hardware reset button ? The effects caused by implementation of feature cause too many self serving complexity. Implementation is well, wrong. What is the feature in application, requiring state of login ? –  May 28 '12 at 07:45

1 Answers1

1

You can't solve your initial problem (mark the user as logged out in the database) this way. Consider another solution, e.g. some datetime column in database table, which will updated periodically by every logged user, telling to your application that user is alive.

Dennis
  • 37,026
  • 10
  • 82
  • 150