SessionChangeReason Enumeration
.NET Framework 2.0
Note: This enumeration is new in the .NET Framework version 2.0.
Specifies the reason for a Terminal Services session change notice.
Namespace: System.ServiceProcess
Assembly: System.ServiceProcess (in system.serviceprocess.dll)
Assembly: System.ServiceProcess (in system.serviceprocess.dll)
| Member name | Description | |
|---|---|---|
| ConsoleConnect | A console session has connected. | |
| ConsoleDisconnect | A console session has disconnected. | |
| RemoteConnect | A remote session has connected. | |
| RemoteDisconnect | A remote session has disconnected. | |
| SessionLock | A session has been locked. | |
| SessionLogoff | A user has logged off from a session. | |
| SessionLogon | A user has logged on to a session. | |
| SessionRemoteControl | The remote control status of a session has changed. | |
| SessionUnlock | A session has been unlocked. |
The following code example shows the use of the SessionChangeReason enumeration in an implementation of the OnSessionChange method in a class derived from ServiceBase. This code example is part of a larger example provided for the ServiceBase class.
' Handle a session change notice
Protected Overrides Sub OnSessionChange(ByVal changeDescription As SessionChangeDescription)
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", _
DateTime.Now.ToLongTimeString() + " - Session change notice recieved: " + _
changeDescription.Reason.ToString() + " Session ID: " + _
changeDescription.SessionId.ToString())
#End If
Select Case changeDescription.Reason
Case SessionChangeReason.SessionLogon
userCount += 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", _
DateTime.Now.ToLongTimeString() + " SessionLogon, total users: " + _
userCount.ToString())
#End If
Case SessionChangeReason.SessionLogoff
userCount -= 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", _
DateTime.Now.ToLongTimeString() + " SessionLogoff, total users: " + _
userCount.ToString())
#End If
Case SessionChangeReason.RemoteConnect
userCount += 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", _
DateTime.Now.ToLongTimeString() + " RemoteConnect, total users: " + _
userCount.ToString())
#End If
Case SessionChangeReason.RemoteDisconnect
userCount -= 1
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", _
DateTime.Now.ToLongTimeString() + " RemoteDisconnect, total users: " + _
userCount.ToString())
#End If
Case SessionChangeReason.SessionLock
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", _
DateTime.Now.ToLongTimeString() + " SessionLock")
#End If
Case SessionChangeReason.SessionUnlock
#If LOGEVENTS Then
System.Diagnostics.EventLog.WriteEntry("SimpleService.OnSessionChange", _
DateTime.Now.ToLongTimeString() + " SessionUnlock")
#End If
Case Else
End Select
End Sub 'OnSessionChange
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Community Additions
ADD
Show: