Global Variables

Answered
1
0

In VWG it was possible to set global variables such that the value once set by a client initiation was common to all clients using the app.

Is this possible in WiseJ?

Thanks

Ewan

  • You must to post comments
Good Answer
0
0

Hi Ewan,

All static (in C#) / Shared (in VB.NET) variables (or properties) are global, meaning all instances (all sessions) have access, according to the variable’s visibility. For instance

static int SharedCounter = 0;

static int SharedCounterProperty {get; set;}

are the shared among all sessions. If you set the value on one session, the others will get the same value.

 

If you want a static variable that isn’t shared, you must use the Session object

  • You must to post comments
0
0

Hi

What happens to the Global variable when a new client joins the party?

Is in re initialised so all existing clients then see the re initialised value or does the new client inherit the current Global variable value?

For example if you wanted to know the number of clients could you have a global variable initialised at zero and incremented when the new client joins (runs the app in their browser)

Eg if I declare in Program.cs

internal static int Calls = 0;

Will it be reset to zero whenever a new client connects?

If this is the case how do you prevent a global variable from reinitialising?

Thanks

Ewan

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.