application scope objects

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • spolsky

    application scope objects

    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.loc k/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="Applicat ion"
    id="rstActiveUs ers" progid="ADODB.R ecordset">
    </object>


    <script language="VBScr ipt" runat="Server">
    Sub Application_OnS tart
    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.Session ID, _
    0, adSearchForward , adBookmarkFirst


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


    -- newuser.asp --
    rstActiveUsers. AddNew
    rstActiveUsers. Fields("id").Va lue = Session.Session ID
    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
    ----

  • Ray Costanzo [MVP]

    #2
    Re: application scope objects


    "spolsky" <spoonersoup@ho tmail.comwrote in message
    news:1159958794 .786682.306810@ m73g2000cwd.goo glegroups.com.. .
    >i use an application scope recordset
    Don't do that!




    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.loc k/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


    Comment

    Working...