是否可以使用计时器删除会话变量?

时间:2016-10-07 19:49:04

标签: vb.net session session-variables

我想使用计时器删除会话变量。我有这门课。

Public Class SessionKiller
    Private WithEvents mclsTimer As Timer
    Private mstrSessionKey As String

    Public Sub New(ByVal lstrSessionKey As String)
        mstrSessionKey = lstrSessionKey

        mclsTimer = New Timer(3000)
        mclsTimer.AutoReset = False
        mclsTimer.Start()
    End Sub

    Private Sub OnTimedEvent(ByVal lobjSource As Object, lclsEvent As ElapsedEventArgs) Handles mclsTimer.Elapsed
        HttpContext.Current.Session.Remove(mstrSessionKey)
    End Sub
End Class

current变量不算什么。是否可以通过这种方式删除会话变量?

1 个答案:

答案 0 :(得分:0)

我使用指向Public Class SessionKiller Private WithEvents mclsTimer As Timer Private mstrSessionKey As String Private mclsSession As HttpSessionStateBase Public Sub New(ByVal lstrSessionKey As String, _ ByVal lclsSession As HttpSessionStateBase) mstrSessionKey = lstrSessionKey mclsSession = lclsSession mclsTimer = New Timer(3000) mclsTimer.AutoReset = False mclsTimer.Start() End Sub Private Sub OnTimedEvent(ByVal lobjSource As Object, lclsEvent As ElapsedEventArgs) Handles mclsTimer.Elapsed mclsSession.Remove(mstrSessionKey) End Sub End Class var。

的指针解决了问题
{{1}}