user1418827
user1418827

Reputation: 19

How to exit C# application gracefully when application is killed through task manager or system restart

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?

Upvotes: 0

Views: 571

Answers (1)

Dennis
Dennis

Reputation: 37760

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.

Upvotes: 1

Related Questions