Imports System.Web.Services
<WebService(Namespace := "http://tempuri.org/")> _
Public Class WSCounter
Inherits System.Web.Services.WebService
Private Sub IncrementGlobalCounter()
Application.Lock()
Application("GlobalCounter") += 1
Application.UnLock()
End Sub
Private Sub IncrementSpecificCounter(ByVal CounterName As String)
Application.Lock()
Application(CounterName) += 1
Application.UnLock()
End Sub
<WebMethod()> Public Sub Method1()
' Increment the global Web Service counter
Me.IncrementGlobalCounter()
'execute Web method code........
End Sub
<WebMethod()> Public Sub Method2()
'Increment the global Web service counter
Me.IncrementGlobalCounter()
'Increment the Web Service specific counter
Me.IncrementSpecificCounter("WSCounter")
'execute Web method code......
End Sub
<WebMethod()> Public Function GetGlobalCounter()
As String
Return Application("GlobalCounter")
End Function
<WebMethod()> Public Function GetSpecificCounter(ByVal CounterName) _
As String
Return Application(CounterName)
End Function
End Class