1Protected Sub Application_Start()Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
2 appRootPath = Me.Context.Request.PhysicalApplicationPath
3
4 InitApplication()
5
6 Dim fsw As New System.IO.FileSystemWatcher(Server.MapPath("."), "*.cfg")
7 Application.Item("FileSystemWatcher") = fsw
8 AddHandler fsw.Created, AddressOf FileSystemWatcherEvent
9 fsw.EnableRaisingEvents = True
10 End Sub
11
12Protected Sub FileSystemWatcherEvent()Sub FileSystemWatcherEvent(ByVal sender As Object, ByVal e As FileSystemEventArgs)
13 If String.Compare(e.Name, "ApplicationUpdate.cfg", True) = 0 Then
14 InitApplication()
15 End If
16End Sub
17
18Private Sub InitApplication()Sub InitApplication()
19 ''读取配置文件
20 ''读取全局内容到变量
21 ''给应用程序变量上线程锁
22 Application.Lock()
23 ''更新应用程序变量
24 Application.Item("Key") = [全局内容变量]
25 ''解应用程序变量线程锁
26 Application.UnLock()
27
28 End Sub
29