SessionChangeDescription.SessionId 屬性

定義

取得相關聯工作階段的工作階段識別碼。

public:
 property int SessionId { int get(); };
public int SessionId { get; }
member this.SessionId : int
Public ReadOnly Property SessionId As Integer

屬性值

相關聯工作階段的工作階段識別碼。

範例

下列程式碼範例示範在 SessionId 衍生自 ServiceBaseOnSessionChange 類別中,方法的實作中使用 屬性。 此程式碼範例是針對 類別提供的較大範例的 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

適用於