asp.net| data
Some special systems require the same time, only one person can modify the system data, when other people modify the data, in the "lock" state, only those who modify the data when the other people can modify the operation.
By setting a global switch variable (application), when the first user modifies the data, the variable is changed to a value that represents the lock state (for example, Lock), and the other user, before modifying the data, checks to see if it can be modified. Usually the right to release the modification (set the variable to unlock)
1. Users who modify the data exit the system
2. Users who modify the data do not operate for a long time
3. The user who modifies the data closes IE
In the first case, we can handle it when the user clicks the "Exit" button.
In the second case, the user does not operate for a long time we can handle in the Session_End event, this time length can be set in Web.config
(The trigger condition of the Session_End event, Session.Abandon () or a long time operation can trigger the event)
In the third case, the user closes IE, if does not handle this kind of situation, actually is not the application object forever in the lock state, ie closes after the Session_End event still can trigger, namely the system will wait until Session_End event triggers can release this resource, But this is not very good, if the trigger Session_End event time is 1 hours ... In this case, we can enter JavaScript in the page, when the user closes the page, jump to a processing exit page, processing finished immediately automatically shut down.
function Window_onunload () {
{
if (Event.clientx < 0 && Event.clienty < 0)
window.open (' logout.aspx ', ', ', ' Toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, Resizable=no,top=2000,left=2000,width=0,height=0 ');
}
We unlock the application variable on the logout.aspx page
This problem also exists in some other applications, such as the real time online user list for a website