void DetectSessionState(object obj) { // 检查当前会话是否被锁定. bool isCurrentLocked = session.IsLocked(); var state = isCurrentLocked ? SessionSwitchReason.SessionLock : SessionSwitchReason.SessionUnlock; // 显示当前状态. lbState.Text = string.Format("当前状态: {0} 时间: {1} ", state, DateTime.Now); // 记录StateChanged事件. lstRecord.Items.Add(string.Format("{0} {1}", DateTime.Now, state)); lstRecord.SelectedIndex = lstRecord.Items.Count - 1; }
void DetectSessionState(object obj) { // Check whether the current session is locked. bool isCurrentLocked = session.IsLocked(); var state = isCurrentLocked ? SessionSwitchReason.SessionLock : SessionSwitchReason.SessionUnlock; // Display the current state. lbState.Text = string.Format("Current State: {0} Time: {1} ", state, DateTime.Now); //string mag=else. // Record the detected result and add it to the list box. lstRecord.Items.Add(string.Format("{0} {1}", DateTime.Now, state)); lstRecord.SelectedIndex = lstRecord.Items.Count - 1; }