Reputation: 1
I want to know how i can do something when exiting a windows application, i wan to run a query UPDATE users SET on = 0; so i know when people are on my program
Main reason for this is i want to do a list of online people for my chat system so they know who they are chatting to i will be doing this with a foreach of where on = 1 in my mysql database users table
i have tryed doing my own close button but what do i do when it is force closed it can be force closed by task manager or if their computer restarts
Upvotes: 0
Views: 90
Reputation: 55571
A program can be killed, an internet connection can go dead or a nuclear bomb could be dropped on a town. The point is, the client can't always do the update.
Update your schema to have a "LastTimeSeen" column and have the other clients use this to decide if a peer is missing and then age that peer out of the system.
Upvotes: 4
Reputation: 4408
Handle the Form.Closing
event:
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.closing.aspx
Upvotes: 0