application scope objects

S

spolsky

i use an application scope recordset object for holding the list of
online users. i am not sure that if i have to handle concurrency issues

like one user is looping through the recordset for getting the list of
online users while another one is getting online so adding a new
record. ado recordset has a free and apartment threading model(marked
ThreadingModel = Both in the registry) so i think it should handle the
concurrency issues and recordset access will not be conflicted.

otherwise, if it could not handle the concurrency i think
- i should put that application scoped recordset into application
collection and use application.lock/unlock methods.
- or serializing the recordset access by an application variable and

locking/unlocking the application for synchronization.
what do you think about these ones?


on the other hand, i know that there are different ways to hold and
provide the list of online users using application variables, database
etc. but i want to clarify the concept of application scope objects to
myself. thus, is there be any concurrency problems with this method? if

so what could
be it done? also what about the efficiency of it?


thanks


--- global.asa ---
<object runat="Server" scope="Application"
id="rstActiveUsers" progid="ADODB.Recordset">
</object>


<script language="VBScript" runat="Server">
Sub Application_OnStart
Const adInteger = 3
Const adVarChar = 200


rstActiveUsers.Fields.Append "id", adInteger
rstActiveUsers.Fields.Append "nick", adVarChar, 50


rstActiveUsers.Open
End Sub
Sub Session_OnEnd
Const adSearchForward = 1
Const adBookmarkFirst = 1
Const adAffectCurrent = 1


rstActiveUsers.Find "id = " & Session.SessionID, _
0, adSearchForward, adBookmarkFirst


If Not rstActiveUsers.EOF Then
rstActiveUsers.Delete adAffectCurrent
End If
End Sub
</script>


-- newuser.asp --
rstActiveUsers.AddNew
rstActiveUsers.Fields("id").Value = Session.SessionID
rstActiveUsers.Fields("nick").Value = RsUser("nick")
rstActiveUsers.Update


-- onlineusers.asp --
Dim fNick
Set fNick = rstActiveUsers.Fields("nick")


If Not rstActiveUsers.EOF Then rstActiveUsers.MoveFirst
While Not rstActiveUsers.EOF
Response.Write(fNick)


rstActiveUsers.MoveNext
If Not rstActiveUsers.EOF Then
Response.Write(",")
End If
Wend
----
 
R

Ray Costanzo [MVP]

spolsky said:
i use an application scope recordset

Don't do that!
http://www.aspfaq.com/show.asp?id=2053



like one user is looping through the recordset for getting the list of
online users while another one is getting online so adding a new
record. ado recordset has a free and apartment threading model(marked
ThreadingModel = Both in the registry) so i think it should handle the
concurrency issues and recordset access will not be conflicted.

See above.

otherwise, if it could not handle the concurrency i think
- i should put that application scoped recordset into application
collection and use application.lock/unlock methods.
- or serializing the recordset access by an application variable and

locking/unlocking the application for synchronization.
what do you think about these ones?

SEE ABOVE!

on the other hand, i know that there are different ways to hold and
provide the list of online users using application variables, database
etc. but i want to clarify the concept of application scope objects to
myself. thus, is there be any concurrency problems with this method? if

so what could
be it done? also what about the efficiency of it?

SEE ABOVE!

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top