Forum  General Visual ...  Let's Chat Abou...  Global Variable question/Clarification
Previous Previous
 
Next Next
New Post 1/27/2009 1:21 AM
  gcsorensen
163 posts
5th Level Poster


Global Variable question/Clarification 

Hi,

I want to confirm that a VB global variable, like userID, can be safely used in a VWG application.

I know that its not 'best practice' to use global variables, but certain items in my app are read once and referenced a lot, and right now, it is too time critical to change the app.

So if 2 users browse to the same VWG app, will the global variables be separate for each user.

I am just being paranoid - it all seems to work OK...

Thanks,

Geoff

 
New Post 1/27/2009 11:34 AM
  palli
11189 posts
1st Level Poster




Re: Global Variable question/Clarification 

Hi Geoff,

Directly from VWG help: "Static variables are shared between users and should be thread safe.", so two users browsing the same VWG app will be accessing the same global variable.

The closest you get to using per-user global variables is using the Context scope, VWGContext.Current("somevar").

Here is another quote from 6.1.x version of VWG help:

Normally web application environments contains there storage scopes which are application scope, session scope and cookies scope. Visual WebGui has an extra storage scope which is the context scope. Every Visual WebGui session can contain several contexts. A context is a scope which has its own main form and manages its own state. A sample usage of the context can be two online application services that are originating from the same web application. Each application is mapped through a different URL and contains its own context scope.   Storing data in the context scope can be a way to replace usages of static variables in a WinForms application as it simulates a confined application context.

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 1/28/2009 4:39 AM
  gcsorensen
163 posts
5th Level Poster


Re: Global Variable question/Clarification 

Thanks, Palli,

(I had read the shorter item in the VWG help - but I wasn't sure - hence the question).

So as I understand it now, my global constants are OK because they don't change, but anything that is specific to a user, that needs to be widely used by the app *must* be converted to a VWGContext.Current("somevar") type/format.

Final confirmation will be appreciated.

Thanks,

Geoff

 
New Post 1/28/2009 1:43 PM
  palli
11189 posts
1st Level Poster




Re: Global Variable question/Clarification 

Hi Geoff,

Yes, correct !

Palli

 


Páll Björnsson - Visual WebGui support team - Email: support@visualwebgui.com
 
New Post 1/28/2009 11:25 PM
  ori.cohen
4383 posts
1st Level Poster




Re: Global Variable question/Clarification 
Modified By ori.cohen  on 5/19/2009 7:39:59 AM)

Hello Geoff,

Yes you are right. You should be aware though that if the session for a specific user dies, the undelying VWG Context object/s die with it. Hence whatever you stored in that storage scope would be gone - reset.

Global / Static variables stay alive as long as the application is alive, like objects and variables stored in the Application scope.

Please reply if you require any further assistance.

Regards,

Ori Cohen
Manager of support, the Visual WebGui team

 
Previous Previous
 
Next Next
  Forum  General Visual ...  Let's Chat Abou...  Global Variable question/Clarification
Assessment Bottom
.NET Web, Cloud and Mobile application delivery platform | Sitemap | Terms of Use | Privacy Statement | Copyright © 2005-2011 Visual WebGui®       Visual WebGui weblog on ASP.NET Visual WebGui Group on LinkedIn Visual WebGui updates on Twitter Visual WebGui Page on Facebook Visual WebGui YouTube Channel Visual WebGui Platform News RSS