"Manuel Arroba" <ma*****@yahoo.com> wrote in message
news:f4**************************@posting.google.c om...
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"?