SessionChangeDescription Structure

 

Identifies the reason for a Terminal Services session change.

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

Public Structure SessionChangeDescription

NameDescription
System_CAPS_pubpropertyReason

Gets the reason for the session change.

System_CAPS_pubpropertySessionId

Gets the session ID for the associated session.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current session change description.(Overrides ValueType.Equals(Object).)

System_CAPS_pubmethodEquals(SessionChangeDescription)

Determines whether the specified session change description is equal to the current session change description.

System_CAPS_pubmethodGetHashCode()

Gets a hash code for the current session change description.(Overrides ValueType.GetHashCode().)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns the fully qualified type name of this instance.(Inherited from ValueType.)

NameDescription
System_CAPS_puboperatorSystem_CAPS_staticEquality(SessionChangeDescription, SessionChangeDescription)

Returns a value indicating whether two SessionChangeDescription structures are equal.

System_CAPS_puboperatorSystem_CAPS_staticInequality(SessionChangeDescription, SessionChangeDescription)

Returns a value indicating whether two SessionChangeDescription structures are not equal.

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 received: " + 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

.NET Framework
Available since 2.0

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

Return to top
Show: