SessionChangeDescription SessionChangeDescription SessionChangeDescription SessionChangeDescription Struct

Definición

Identifica el motivo de un cambio de la sesión de Terminal Services.Identifies the reason for a Terminal Services session change.

public value class SessionChangeDescription
public struct SessionChangeDescription
type SessionChangeDescription = struct
Public Structure SessionChangeDescription
Herencia
SessionChangeDescriptionSessionChangeDescriptionSessionChangeDescriptionSessionChangeDescription

Ejemplos

En el ejemplo de código siguiente se muestra el SessionChangeDescription uso de la clase en una OnSessionChange implementación del método en una clase ServiceBasederivada de.The following code example shows the use of the SessionChangeDescription class in an implementation of the OnSessionChange method in a class derived from ServiceBase. Este ejemplo de código forma parte de un ejemplo más extenso proporcionado ServiceBase para la clase.This code example is part of a larger example provided for the ServiceBase class.

        // Handle a session change notice
        protected override void OnSessionChange(SessionChangeDescription changeDescription)
        {
#if LOGEVENTS
            EventLog.WriteEntry("SimpleService.OnSessionChange", DateTime.Now.ToLongTimeString() +
                " - Session change notice received: " +
                changeDescription.Reason.ToString() + "  Session ID: " +
                changeDescription.SessionId.ToString());
#endif

            switch (changeDescription.Reason)
            {
                case SessionChangeReason.SessionLogon:
                    userCount += 1;
#if LOGEVENTS
                    EventLog.WriteEntry("SimpleService.OnSessionChange",
                        DateTime.Now.ToLongTimeString() +
                        " SessionLogon, total users: " +
                        userCount.ToString());
#endif
                    break;
                case SessionChangeReason.SessionLogoff:

                    userCount -= 1;
#if LOGEVENTS
                    EventLog.WriteEntry("SimpleService.OnSessionChange",
                        DateTime.Now.ToLongTimeString() +
                        " SessionLogoff, total users: " +
                        userCount.ToString());
#endif
                    break;
                case SessionChangeReason.RemoteConnect:
                    userCount += 1;
#if LOGEVENTS
                    EventLog.WriteEntry("SimpleService.OnSessionChange",
                        DateTime.Now.ToLongTimeString() +
                        " RemoteConnect, total users: " +
                        userCount.ToString());
#endif
                    break;
                case SessionChangeReason.RemoteDisconnect:
                    userCount -= 1;
#if LOGEVENTS
                    EventLog.WriteEntry("SimpleService.OnSessionChange",
                        DateTime.Now.ToLongTimeString() +
                        " RemoteDisconnect, total users: " +
                        userCount.ToString());
#endif
                    break;
                case SessionChangeReason.SessionLock:
#if LOGEVENTS
                    EventLog.WriteEntry("SimpleService.OnSessionChange",
                        DateTime.Now.ToLongTimeString() +
                        " SessionLock");
#endif
                    break;
                case SessionChangeReason.SessionUnlock:
#if LOGEVENTS
                    EventLog.WriteEntry("SimpleService.OnSessionChange",
                        DateTime.Now.ToLongTimeString() +
                        " SessionUnlock");
#endif
                    break;
                default:
                    break;
            }
        }
    ' 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

Propiedades

Reason Reason Reason Reason

Obtiene la razón para el cambio de la sesión.Gets the reason for the session change.

SessionId SessionId SessionId SessionId

Obtiene el identificador de sesión para la sesión asociada.Gets the session ID for the associated session.

Métodos

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual a la descripción del cambio de la sesión actual.Determines whether the specified object is equal to the current session change description.

Equals(SessionChangeDescription) Equals(SessionChangeDescription) Equals(SessionChangeDescription) Equals(SessionChangeDescription)

Determina si la descripción de cambio de sesión especificada es igual a la descripción de cambio de sesión actual.Determines whether the specified session change description is equal to the current session change description.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Obtiene un código hash para la descripción de cambio de sesión actual.Gets a hash code for the current session change description.

Operadores

Equality(SessionChangeDescription, SessionChangeDescription) Equality(SessionChangeDescription, SessionChangeDescription) Equality(SessionChangeDescription, SessionChangeDescription) Equality(SessionChangeDescription, SessionChangeDescription)

Devuelve un valor que indica si dos estructuras SessionChangeDescription son iguales.Returns a value indicating whether two SessionChangeDescription structures are equal.

Inequality(SessionChangeDescription, SessionChangeDescription) Inequality(SessionChangeDescription, SessionChangeDescription) Inequality(SessionChangeDescription, SessionChangeDescription) Inequality(SessionChangeDescription, SessionChangeDescription)

Devuelve un valor que indica si dos estructuras SessionChangeDescription no son iguales.Returns a value indicating whether two SessionChangeDescription structures are not equal.

Se aplica a