Bagikan melalui


SessionChangeDescription.SessionId Properti

Definisi

Mendapatkan ID sesi untuk sesi terkait.

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

Nilai Properti

ID sesi untuk sesi terkait.

Contoh

Contoh kode berikut menunjukkan penggunaan SessionId properti dalam implementasi OnSessionChange metode dalam kelas yang berasal dari ServiceBase. Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk ServiceBase kelas .

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

Berlaku untuk