SessionChangeReason SessionChangeReason SessionChangeReason SessionChangeReason Enum

Definizione

Specifica il motivo di un avviso di modifica di sessione di Servizi terminal.Specifies the reason for a Terminal Services session change notice.

public enum class SessionChangeReason
public enum SessionChangeReason
type SessionChangeReason = 
Public Enum SessionChangeReason
Ereditarietà
SessionChangeReasonSessionChangeReasonSessionChangeReasonSessionChangeReason

Campi

ConsoleConnect ConsoleConnect ConsoleConnect ConsoleConnect 1

Una sessione della console si è connessa.A console session has connected.

ConsoleDisconnect ConsoleDisconnect ConsoleDisconnect ConsoleDisconnect 2

Una sessione della console si è disconnessa.A console session has disconnected.

RemoteConnect RemoteConnect RemoteConnect RemoteConnect 3

Una sessione remota si è connessa.A remote session has connected.

RemoteDisconnect RemoteDisconnect RemoteDisconnect RemoteDisconnect 4

Una sessione remota si è disconnessa.A remote session has disconnected.

SessionLock SessionLock SessionLock SessionLock 7

Una sessione è stata bloccata.A session has been locked.

SessionLogoff SessionLogoff SessionLogoff SessionLogoff 6

Un utente si è disconnesso da una sessione.A user has logged off from a session.

SessionLogon SessionLogon SessionLogon SessionLogon 5

Un utente si è connesso a una sessione.A user has logged on to a session.

SessionRemoteControl SessionRemoteControl SessionRemoteControl SessionRemoteControl 9

Lo stato del controllo remoto di una sessione è cambiato.The remote control status of a session has changed.

SessionUnlock SessionUnlock SessionUnlock SessionUnlock 8

Una sessione è stata sbloccata.A session has been unlocked.

Esempi

Nell'esempio di codice seguente viene illustrato l'utilizzo SessionChangeReason dell'enumerazione in un'implementazione OnSessionChange del metodo in una classe derivata da ServiceBase.The following code example shows the use of the SessionChangeReason enumeration in an implementation of the OnSessionChange method in a class derived from ServiceBase. Questo esempio di codice fa parte di un esempio più ampio fornito ServiceBase per la classe.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

Si applica a