SessionChangeDescription SessionChangeDescription SessionChangeDescription SessionChangeDescription Struct

Definition

Gibt den Grund für eine Terminaldienste-Sitzungsänderung an.Identifies the reason for a Terminal Services session change.

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

Beispiele

Im folgenden Codebeispiel wird die Verwendung SessionChangeDescription der-Klasse in einer Implementierung OnSessionChange der-Methode in einer Klasse veranschaulicht, ServiceBasedie von abgeleitet ist.The following code example shows the use of the SessionChangeDescription class in an implementation of the OnSessionChange method in a class derived from ServiceBase. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die ServiceBase -Klasse bereitgestellt wird.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

Eigenschaften

Reason Reason Reason Reason

Ruft den Grund für die Sitzungsänderung ab.Gets the reason for the session change.

SessionId SessionId SessionId SessionId

Ruft die Sitzungs-ID für die zugehörige Sitzung ab.Gets the session ID for the associated session.

Methoden

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

Bestimmt, ob das angegebene Objekt gleich der aktuellen Sitzungsänderungsbeschreibung ist.Determines whether the specified object is equal to the current session change description.

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

Bestimmt, ob die angegebene Sitzungsänderungsbeschreibung gleich der aktuellen Sitzungsänderungsbeschreibung ist.Determines whether the specified session change description is equal to the current session change description.

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

Ruft einen Hashcode für die aktuelle Beschreibung der Sitzungsänderung ab.Gets a hash code for the current session change description.

Operatoren

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

Gibt einen Wert zurück, der angibt, ob zwei SessionChangeDescription-Strukturen gleich sind.Returns a value indicating whether two SessionChangeDescription structures are equal.

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

Gibt einen Wert zurück, der angibt, ob zwei SessionChangeDescription-Strukturen ungleich sind.Returns a value indicating whether two SessionChangeDescription structures are not equal.

Gilt für: