我想使用计时器删除会话变量。我有这门课。
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
变量不算什么。是否可以通过这种方式删除会话变量?
答案 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}}