[CODE]
Imports System.Collections
Public Class StaticContainer
Private Shared thing As Hashtable
Public Shared Sub InitThing()
thing = New Hashtable()
End Sub
Public Shared Sub KillThing()
thing.Clear()
thing = Nothing
End Sub
Public Shared Sub AddContainer(ByVal key As Object)
thing.Add(key, New ArrayList())
End Sub
Public Shared Sub RemoveContainer(ByVal key As Object)
thing.Remove(key)
End Sub
Public Shared Sub AddToContainer(ByVal newname As String, ByVal index As Integer,
ByVal stuff As String, ByVal key As Object)
Dim temp As ArrayList = thing.Item(key)
thing.Remove(key)
Dim t As New triple()
t.name = newname
t.ID = index
t.data = stuff
temp.Add(t)
thing.Add(key, temp)
End Sub
Public Shared Function GetEntry(ByVal x As Integer, ByVal key As Object) As triple
Dim temp As ArrayList = thing.Item(key)
Dim result As triple
If temp.Count > x And x >= 0 Then
result = CType(temp(x), triple)
End If
Return result
End Function
End Class
Public Structure triple
Public name As String
Public ID As Integer
Public data As String
End Structure
[/CODE]
In global.asax
[CODE]
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application is started
StaticContainer.InitThing()
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session is started
Session.Add("key", DateTime.Now.Ticks.ToString("x"))
StaticContainer.AddContainer(Session.Item("key"))
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
StaticContainer.RemoveContainer(Session.Item("key"))
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the application ends
StaticContainer.KillThing()
End Sub
[/CODE]
CHECK THIS LINK FOR MORE EXPLAINATION
http://www.dotnetjunkies.com/Tutorial/FA28D27E-82ED-4B91-96E4-65C97F6B6DBE.dcik