SessionChangeDescription 구조체

정의

터미널 서비스 세션 변경의 원인을 식별합니다.Identifies the reason for a Terminal Services session change.

public value class SessionChangeDescription
public struct SessionChangeDescription
type SessionChangeDescription = struct
Public Structure SessionChangeDescription
상속
SessionChangeDescription

예제

다음 코드 예제에서는 SessionChangeDescription OnSessionChange 에서 파생 된 클래스의 메서드 구현에서 클래스를 사용 하는 방법을 보여 줍니다 ServiceBase .The following code example shows the use of the SessionChangeDescription class in an implementation of the OnSessionChange method in a class derived from ServiceBase. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 ServiceBase 클래스입니다.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

속성

Reason

세션 변경의 원인을 가져옵니다.Gets the reason for the session change.

SessionId

연관된 세션에 대한 세션 ID를 가져옵니다.Gets the session ID for the associated session.

메서드

Equals(Object)

지정한 개체가 현재 세션 변경 설명과 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current session change description.

Equals(SessionChangeDescription)

지정한 세션 변경 설명이 현재 세션 변경 설명과 같은지 여부를 결정합니다.Determines whether the specified session change description is equal to the current session change description.

GetHashCode()

현재 세션 변경 설명에 대한 해시 코드를 가져옵니다.Gets a hash code for the current session change description.

연산자

Equality(SessionChangeDescription, SessionChangeDescription)

SessionChangeDescription 구조체가 같은지 여부를 나타내는 값을 반환합니다.Returns a value indicating whether two SessionChangeDescription structures are equal.

Inequality(SessionChangeDescription, SessionChangeDescription)

SessionChangeDescription 구조체가 다른지 여부를 나타내는 값을 반환합니다.Returns a value indicating whether two SessionChangeDescription structures are not equal.

적용 대상