次の方法で共有


SessionChangeDescription.Reason プロパティ

定義

セッション変更の理由を取得します。

public:
 property System::ServiceProcess::SessionChangeReason Reason { System::ServiceProcess::SessionChangeReason get(); };
public System.ServiceProcess.SessionChangeReason Reason { get; }
member this.Reason : System.ServiceProcess.SessionChangeReason
Public ReadOnly Property Reason As SessionChangeReason

プロパティ値

SessionChangeReason値の 1 つ。

次のコード例は、ServiceBase から派生したクラスのOnSessionChange メソッドの実装でReason プロパティを使用する方法を示しています。 このコード例は、 ServiceBase クラスに提供されるより大きな例の一部です。

        // 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
    ' 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

適用対象