Statics
Static Variables
Static variables in Wisej.NET are just regular C# static variables. They have the same value and are accessible across all client sessions. A static variable has one copy per AppDomain. So, if the AppDomain or AppPool resets, the value of the static variable resets.
You can create a static variable like so:
public static string myStaticVariable = "hello";Static Events
In Wisej.NET, a static event is just a normal C# static event — and that means there is exactly one event + one subscriber list per application instance on the server, shared by all browser sessions. In other words, when static events in Wisej.NET fire, they fire in all sessions.
You can create a static event like so:
public static event EventHandler MyStaticEvent;And attach a handler to the event like so:
MyStaticEvent += MyStaticEvent_Fired;
private void MyStaticEvent_Fired(object sender, EventArgs e)
{
//code that runs when the event is fired
}You can fire the event like so:
MyStaticEvent?.Invoke(null, EventArgs.Empty);Note that when a static event fires, it is out-of-context; it's associated with the sender's session. So if you want to do something session-specific like updating the UI when a static event fires, you’ll need to use Application.Update:
In our case, this represents the context of the current browser session. By passing in this, we tell the application to run in the context of our current browser session, which allows us to update the UI for that session.
Last updated
Was this helpful?

