Session state

Discussion in 'ASP .Net Web Services' started by Alex, Apr 21, 2010.

  1. Alex

    Alex Guest

    I have a WS that contains multiple classes and web methods. We need to keep
    track of execution times. To do this, I created a class with two properties,
    one of them is a unique "ThreadId" which is a simple random string. The
    reason for this is that we need to keep track of execution times through all
    methods. E.g. GetUser() calls a Login() method, and then calls the GetUser
    data access method, then calls a DataSetToJSON method etc, so the theory is
    that when we query the execution times, we can see the stack trace and group
    it by the ThreadId.

    The problem is that when we have multiple hits to the WS, the ThreadId is
    being "shared" among different connections. I assumed that each new WS call
    will get it's own ThreadId, but this is not the case.

    How can I create this object containing the threadId for each specific
    connection?

    Thanks
    Alex, Apr 21, 2010
    #1
    1. Advertising

  2. Alex

    Alex Guest

    An Example is when User1 calls a web method, I generate a "ThreadId" string
    and log that in the database. When User2 calls a web method in the same
    class, it too generates a different ThreadId. But in some cases, when traffic
    is high, it looks like the same ThreadId is being used by different users.
    Alex, Apr 21, 2010
    #2
    1. Advertising

  3. Alex

    Patrice Guest

    Hello,

    > I have a WS that contains multiple classes and web methods. We need to
    > keep
    > track of execution times. To do this, I created a class with two
    > properties,
    > one of them is a unique "ThreadId" which is a simple random string. The
    > reason for this is that we need to keep track of execution times through
    > all
    > methods. E.g. GetUser() calls a Login() method, and then calls the GetUser
    > data access method, then calls a DataSetToJSON method etc, so the theory
    > is
    > that when we query the execution times, we can see the stack trace and
    > group
    > it by the ThreadId.


    How do you create those "thread id" ? You could likely unit test your thread
    id generator to see if you get duplicates...

    AFAIK the session state module creates session ids by creating a guid that
    is then turned into a string (base 64 encoded ?). You could perhaps use
    something similar. Strictly speaking, uniqueness is not enforced but if you
    ever come accross a collision you are really out of luck (i.e. something
    like getting the same value twice when you have 10 power 36 possible
    values)...

    Also it is still possible that you have some kind of programming error
    (notably using C# static or VB shared data). How do you keep this thread id
    accross calls ?

    --
    Patrice
    Patrice, Apr 21, 2010
    #3
  4. Alex

    Alex Guest

    The string generation is pretty unique. But I think the issue is in the code.
    I'm using InvokeMember to execute methods (used for version control) and I
    think it's none-managed code, and coupled with the fact that I'm using a
    static data object, the results are that some "connections" use the same
    object.

    I'm about to test this and will update the thread.

    Thanks for the reply.
    Alex, Apr 21, 2010
    #4
  5. Alex

    Alex Guest

    That was it. InvokeMember makes the class loose state. There goes a day that
    I'll never get back...
    Alex, Apr 21, 2010
    #5
  6. Alex

    Patrice Guest

    Yes, static data are shared by the whole application. The point to keep in
    mind is that a web application is a *single* application used by multiple
    users at the same time so all static data are shared accross those users...

    --
    Patrice

    "Alex" <.(nospam)> a écrit dans le message de groupe de
    discussion : ...
    > The string generation is pretty unique. But I think the issue is in the
    > code.
    > I'm using InvokeMember to execute methods (used for version control) and I
    > think it's none-managed code, and coupled with the fact that I'm using a
    > static data object, the results are that some "connections" use the same
    > object.
    >
    > I'm about to test this and will update the thread.
    >
    > Thanks for the reply.
    >
    Patrice, Apr 22, 2010
    #6
    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. shamanthakamani
    Replies:
    1
    Views:
    3,473
    Natty Gur
    Nov 20, 2003
  2. Not Liking Dot Net Today
    Replies:
    0
    Views:
    593
    Not Liking Dot Net Today
    Apr 21, 2004
  3. Maciek
    Replies:
    0
    Views:
    8,227
    Maciek
    Sep 15, 2005
  4. jnickfl1
    Replies:
    0
    Views:
    572
    jnickfl1
    Sep 18, 2006
  5. Harry Haller
    Replies:
    0
    Views:
    1,640
    Harry Haller
    Nov 7, 2006
Loading...

Share This Page