Click to See Complete Forum and Search --> : ASP code runs only one at a time


Andrew Waycott
02-27-1999, 04:15 PM
I have an IIS 4.0 server running ASP 2 (VBScript) code. When I run the below code from two different clients at the same time, they run one at a time instead of simultaneously. Is there a way to make IIS and ASP work so that both instances of the code run at the same time? Please note that this is just test code and that the same thing happens when I run any code that takes a long time to run like code that calls a stored procedure on a SQL server.

Andrew
==============================
<%option explicit%>

<%

Dim GlobalSeconds
GlobalSeconds=10

Response.write "<br>Start: <br>"
Response.write now()
Call Timer(GlobalSeconds)
Response.Write "<br>Expire timeout:<br>"
Response.write now

Sub Timer(LocalSeconds)
Dim StartDate
Dim CurrentDate
Dim Counter
Dim I
Dim MultiplyFactor

MultiplyFactor=2000 ' 1 second

StartDate=Now

While I< (LocalSeconds*MultiplyFactor*2)
I = I + 1
For Counter = 1 to 1000
Next
CurrentDate=Now

If Datediff("s", StartDate, CurrentDate)> (LocalSeconds-1) Then
I=(LocalSeconds*MultiplyFactor*2)
End If

Wend
End Sub

%>

Sebastian Bologescu
03-02-1999, 12:28 PM
Hi,

In ASP variable scope have three levels:
1. Application - the IIS allocate only one instance for the variable and all users "see" it
This kind of variable born when IIS starts and die when IIS shutdown
2. Session - the IIS allocate one instance for each user (session) who are connected on the HTTP server and each user "see" only his instance allocated (the user cannot "see" instances from the same variable from another user)
This kind of variable born when a new connection appear (a new user appear) and die when the user is disconnected
3. Page - the same thing like Session but it born when a user visit the page and die when a user leave the page

You can declare a variable in three modes:

Application("my_var") = 0 ' this is the Application level
Session("my_var") = 0 ' this is the Session level
my_var = 0 ' this is the Page level

If you want to create an ASP page who can work interactive with all users at the same time in the same mode you need to use the Session level.

Good luck,
Sebastian Bologescu

On 2/27/99 5:15:11 PM, Andrew Waycott wrote:
> I have an IIS 4.0 server running ASP 2 (VBScript) code. When I run the
> below code from two different clients at the same time, they run one at a
> time instead of simultaneously. Is there a way to make IIS and ASP work so
> that both instances of the code run at the same time? Please note that
> this is just test code and that the same thing happens when I run any code
> that takes a long time to run like code that calls a stored procedure on a
> SQL server.

Andrew
==============================
<%option
> explicit%>

<%

Dim GlobalSeconds
GlobalSeconds=10

Response.write
> "<br>Start: <br>"
Response.write now()
Call
> Timer(GlobalSeconds)
Response.Write "<br>Expire timeout:<br>"

> Response.write now

Sub Timer(LocalSeconds)
Dim StartDate
Dim
> CurrentDate
Dim Counter
Dim I
Dim MultiplyFactor


> MultiplyFactor=2000 ' 1 second

StartDate=Now

While I<
> (LocalSeconds*MultiplyFactor*2)
I = I + 1
For Counter = 1 to
> 1000
Next
CurrentDate=Now

If Datediff("s", StartDate,
> CurrentDate)> (LocalSeconds-1) Then
I=(LocalSeconds*MultiplyFactor*2)
>
End If

Wend
End Sub

%>