Variable values collision in multiuser environment

Discussion in 'ASP .Net' started by Manuel Arroba, Jun 6, 2004.

  1. I had the idea that two users code are being run by two different
    instancies, so from the variable values point of view they are
    complete independent.

    I have an asp.net that calls a module rutine.

    When there are two users accessing to the module rutine, looks like
    asp.net is sharing variable values. For example, in one point I check
    the size of the table (from debug for example I now is 3) but is
    reporting an incorrect size (let says 5 that comes from the table of
    the second user).

    The question I am not sure if this is wad or I am doing something
    wrong.

    Thanks in advance...
     
    Manuel Arroba, Jun 6, 2004
    #1
    1. Advertising

  2. "Manuel Arroba" <> wrote in message
    news:...
    > I had the idea that two users code are being run by two different
    > instancies, so from the variable values point of view they are
    > complete independent.
    >
    > I have an asp.net that calls a module rutine.
    >
    > When there are two users accessing to the module rutine, looks like
    > asp.net is sharing variable values. For example, in one point I check
    > the size of the table (from debug for example I now is 3) but is
    > reporting an incorrect size (let says 5 that comes from the table of
    > the second user).
    >
    > The question I am not sure if this is wad or I am doing something
    > wrong.


    One thing you're doing wrong is not giving us much detail. :)

    Where are the variables you believe are being shared? I bet they are
    module-level variables, in which case they will be shared, as there is only
    one instance of the module, not one per page request.
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 6, 2004
    #2
    1. Advertising

  3. Hi John thank you very much for your answer...

    I did not post any code because I think it was a general question.

    I have a page that is calling a rutine in a module file (.vb).

    Public Structure DatosRutaConDatos
    Public TodoOk As Boolean
    Public tabla As DataTable
    Public TextoError As String
    End Structure
    Module RutinasSincronizacion
    Dim InstanciaDatosRuta As New DatosRuta()
    Public Function BuscaInfo(ByVal tb As DataTable, ByVal Centro As
    String) As DatosRutaConDatos
    ....
    end function
    ...
    end module


    The problem arises when two users (two pages) call the same rutine
    (BuscaInfo) at the same time. Some variables look that are not shared,
    but I have problems with the InstanciaDatosRuta.

    I had the idea that any code should not be shared.

    Does it mean that we cannot use modules files ?... it looks a bit
    strange.

    Would you mind to confirm this point ?...
    Thanks again... have a nice day
    Manuel Arroba
     
    Manuel Arroba, Jun 7, 2004
    #3
  4. "Manuel Arroba" <> wrote in message
    news:...
    > Hi John thank you very much for your answer...
    >
    > I did not post any code because I think it was a general question.
    >
    > I have a page that is calling a rutine in a module file (.vb).
    >
    > Public Structure DatosRutaConDatos
    > Public TodoOk As Boolean
    > Public tabla As DataTable
    > Public TextoError As String
    > End Structure
    > Module RutinasSincronizacion
    > Dim InstanciaDatosRuta As New DatosRuta()
    > Public Function BuscaInfo(ByVal tb As DataTable, ByVal Centro As
    > String) As DatosRutaConDatos
    > ...
    > end function
    > ..
    > end module
    >
    >
    > The problem arises when two users (two pages) call the same rutine
    > (BuscaInfo) at the same time. Some variables look that are not shared,
    > but I have problems with the InstanciaDatosRuta.
    >
    > I had the idea that any code should not be shared.
    >
    > Does it mean that we cannot use modules files ?... it looks a bit
    > strange.


    Manuel, InstanciaDatosRuta will be shared by all users of the module. What
    would have caused a new copy of InstanciaDatosRuta to be created?

    You should probably avoid modules when working in VB.NET. They are a pre-OO
    construct.

    If you want a separate instance of InstanciaDatosRuta to exist per user,
    then you're going to have to explicitly create the separate instance
    somehow. For instance:

    Public Structure DatosRutaConDatos
    Public TodoOk As Boolean
    Public tabla As DataTable
    Public TextoError As String
    End Structure
    Public Class RutinasSincronizacion
    Private InstanciaDatosRuta As New DatosRuta()
    Public Function BuscaInfo(ByVal tb As DataTable, ByVal Centro As
    String) As DatosRutaConDatos
    ....
    end function
    ...
    End Class


    You will need to have some piece of code create an instance of the class
    RutinasSincronizacion. Perhaps such an instance would be stored in Session:

    If Session("RutinasSincronizacion") Is Nothing Then
    Session("RutinasSincronizacion") = New RutinasSincronizacion()
    End If

    Dim RS As RutinasSincronizacion =
    DirectCast(Session("RutinasSincronizacion"), RutinasSincronizacion)

    Dim DRCD As DatosRutaConDatos = RS.BuscaInfo(tb, "centro")
    --
    John Saunders
    johnwsaundersiii at hotmail

    P.S. Please pardon my high-school Spanish, but what's a "Ruta"?
     
    John Saunders, Jun 7, 2004
    #4
  5. Hi John, thanks for you answer and your code sugestion..

    I only can help you with you spanish.. :)

    Ruta is like "path". In this case is the path that follow some
    products in a factory...

    Thanks again, and have a nice day...
     
    Manuel Arroba, Jun 7, 2004
    #5
  6. "Manuel Arroba" <> wrote in message
    news:...
    > Hi John, thanks for you answer and your code sugestion..
    >
    > I only can help you with you spanish.. :)
    >
    > Ruta is like "path". In this case is the path that follow some
    > products in a factory...


    Thanks, this shows I'm getting old. I used to know "ruta" (which is akin to
    "route" in English).
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 8, 2004
    #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. Michael A. Covington

    Setting up Eclipse in a multiuser environment

    Michael A. Covington, Feb 5, 2004, in forum: Java
    Replies:
    1
    Views:
    1,402
    Neil Campbell
    Feb 5, 2004
  2. philip
    Replies:
    3
    Views:
    394
    Bruno Alexandre
    Aug 18, 2006
  3. Replies:
    5
    Views:
    702
  4. nelson -
    Replies:
    0
    Views:
    275
    nelson -
    Jul 14, 2009
  5. Replies:
    5
    Views:
    166
Loading...

Share This Page