SessionChangeDescription Structure

Identifies the reason for a Terminal Services session change.

Namespace: System.ServiceProcess
Assembly: System.ServiceProcess (in system.serviceprocess.dll)

'Declaration
Public Structure SessionChangeDescription
'Usage
Dim instance As SessionChangeDescription

public final class SessionChangeDescription extends ValueType
Not applicable.

The following code example shows the use of the SessionChangeDescription class 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


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show: