application scope objects

Discussion in 'ASP General' started by spolsky, Oct 4, 2006.

  1. spolsky

    spolsky Guest

    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
    ----
     
    spolsky, Oct 4, 2006
    #1
    1. Advertising

  2. "spolsky" <> wrote in message
    news:...
    >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
     
    Ray Costanzo [MVP], Oct 4, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    1,010
    Paul Opal
    Oct 11, 2004
  2. ann
    Replies:
    13
    Views:
    698
    Patricia Shanahan
    Sep 13, 2005
  3. Steven T. Hatton
    Replies:
    9
    Views:
    523
  4. Xah Lee
    Replies:
    0
    Views:
    2,286
    Xah Lee
    Feb 26, 2009
  5. Replies:
    0
    Views:
    184
Loading...

Share This Page