Howdy,
I’ve been putting variables globally in a module, but learned that they are globally to ALL sessions, so they mixed up with everyone accessing the system.
Ex: public StrX as string = string.empty
=> this in a global module.
1st question:
– if I use variables inside a form, like: dim StrZ as string = string.empty
They are available JUST for the user session, or globally?
2nd question:
– I need to use global dataset and datatables for the user session, and I’m currently declaring it on the module as: public LkParam as datatable
Which will be available to everyone accessing the system/all sessions, so, why could I set this variable in the wisej sessions variables? For example in Main sub;
Application.Session.LkParams = new datatable
Would this be correct? another more correct way to do it?
thanks in advanced,
Ok,
When i said wisej you understood,
So, a public str as string in a module is accessible across all sessions/threads.
and a “dim str as string” only in a form?
i’m using Application.Session.LkParams to be sure they exists only in the session/thread.
Wisej doesn’t have global variables or any other kind. It’s not a language or a complier. It’s a .NET framework written in C#.
Statics (globals in VB.NET), instance, local variables are all standard variable scopes that are mostly identical across languages. Wisej doesn’t change the way .NET works.
You can use statics that are shared across the app domain, or you can use instance variables declared in a form or page or save them in the session object.
The session (Application.Session) is a web concept that doesn’t exist in any language. Web frameworks (like Wisej) use a static cache to store a container associated to a unique key created and stored in the client browser. Web frameworks (like Wisej) restore the session container at the beginning of every request.
Additionally, when you use static (shared resources) you should take care of the synchronization because they can be accessed by multiple threads at the same time. Look up thread synchronization in VB.NET or C#.
HTH
Please login first to submit.