Skip to main content
Version: 3.5

Application

Namespace: Wisej.Web

Assembly: Wisej.Framework (3.5.0.0)

Represent a Wisej application session. Provides methods and events to manage the application in the context of the current session.

public class Application : IWisejComponent, IDisposable, IWisejSynchronized

This class provides several static methods, properties and events that allow the application to manage all sorts of features related to the current session:

  • Save and retrieve session variable. Use Session to store and retrieve session variable. The property is a dynamic object and a Dictionary, therefore you can access its properties directly or through the indexer.

Application.Session.myValue = 12;
Application.Session["myValue"] = 12;

  • Manage cookies. Use Cookies to manage browser's cookies.
  • Read server variables. Use ServerVariables to retrieve all the data made available by the server. Some of the variables in the collection are also available directly: ServerPort, ServerName, UserAgent, etc.
  • Read the application's URL. Use Uri, Url, StartupUri, and StartupUrl.
  • Read the application's system information. Use StartupPath, ProductName, ProductVersion, etc.
  • Listen to the application's global events. See SessionTimeout , BeginRequest, ApplicationStart, ApplicationExitApplicationRefresh, BrowserSizeChangedResponsiveProfileChanged, CultureChanged, and many more.
  • Retrieve browser related information. Use the Browser to read the client browser type, OS, version, capabilities, screen size, browser size, language, and state. The Browser object is updated automatically when the user resizes the browser or the page is reloaded.
  • Control the client browser. Start a Download, execute JavaScript functions or scriptlets using Call or Eval. Make the browser navigate to a different URL using Navigate or simply Reload the page.
  • Manage the main page or current desktop. MainPage lets you change the Page object that fills the browser and "navigate" from page to page. Desktop lets you change the active Desktop object on the client browser.
  • Manage all live components in the session. Through the Application class you can find, iterate, inspect all live components of any type. See OpenForms for all the currently created (visible or invisible) instances of Form. OpenPages returns all the created Page objects. FindComponent and FindComponents provide an easy way to find any component in the session or to iterate the list of components that match a custom expression.
  • Start background tasks in context. StartTask provides a powerful way to start a background task on the server that can keep interacting with the client browser while running independently.
  • Manage the application's theme. Use LoadTheme to load a Wisej theme into the application. Or use the Theme object to read all sorts of information from the current ClientTheme.
  • Terminate the application without waiting for the session to timeout. Use Exit to terminate the current session and free all the related memory.

There is a lot more exposed by the Application class. You can inspect all the properties and methods in Visual Studio through IntelliSense or online at docs.wisej.

Properties

Static memberActiveProfile

ClientProfile: Returns or sets the current client responsive profile.

This is the profile that best matches the current browser on the client. It is updated automatically on every request.

Static memberBrowser

ClientBrowser: Returns or the client browser's information.

Static memberClientCertificate

X509Certificate2: EXPERIMENTAL: Provides the client certificate fields issued by the client in response to the server's request for the client's identity. Since 3.5.6

Static memberClientId

String: Returns the current unique client id.

Static memberClients

ClientCollection: Returns a collection of all the unique client browsers using the application.

Static memberCommandManager

CommandManager: Returns the current CommandManager.

Static memberCommonAppDataPath

String: Returns the path for the application data that is shared among all users.

Static memberCommonAppDataRegistry

RegistryKey: Returns the registry key for the application data that is shared among all users.

Static memberCompanyName

String: Returns the company name associated with the application stored in the AssemblyCompanyAttribute.

Static memberConfiguration

Configuration: Returns the current Configuration.

Static memberCookies

CookieCollection: Collection of cookies.

Static memberCurrent

IWisejComponent: Returns the application component instance that an application can store and use later to restore the context when updating client widgets during an out-of-bound call using the Update method.

Threads that are not started using StartTask don't have any knowledge of the current session and don't have a way to communicate with the client The Current property returns the instance of the Application class that is bound to the current session. It can be used just like any other component with the method Update or RunInContext to restore the session for the current thread. The advantage of using Current instead of the instance of a control or a page is to avoid to keep a reference to a component that may be disposed by the application.


var current = Application.Current;
var thread = new Thread(() => {
Application.Update(current, () => {

// code here is running in context.

});
});

Static memberCurrentCulture

CultureInfo: Returns or sets the current CultureInfo for the session.

Static memberDesktop

Desktop: Returns or sets the current Desktop.

Static memberEnableUnloadConfirmation

Boolean: Returns or sets whether the browser will ask the user to confirm unloading the current page.

This property attaches the window.onbeforeunload event. See https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload. It's not possible to determine whether the page is being unloaded because the user is trying to close the tab, close the browser, or is refreshing the page, or is taking any other action that may reload the page.

Static memberExecutablePath

String: Returns the path for the application's main assembly.

Static memberFavIcon

Image: Returns or sets the favicon to display in the browser.

Static memberFavIconSource

String: Returns or sets the URL to the favicon to display in the browser.

Static memberHash

String: Returns or sets the hash part of the URL on the client.

Static memberIsAuthenticated

Boolean: Returns a value indicating whether the session has been authenticated.

Instance memberIsDisposed

Boolean: Indicates that the current application instance, which corresponds to the session, has been terminated and disposed.

Static memberIsExpired

Boolean: Returns true when the current session has expired.

Static memberIsSecure

Boolean: Returns true if this session is running in secure mode (https:// and wss://)

Static memberIsTerminated

Boolean: Returns true when the current session has been terminated.

Static memberIsWebSocket

Boolean: Returns true if the current session is connected using WebSocket.

Static memberLicenseInfo

Object: Returns a dynamic object containing the currently loaded license information. Since 3.1.3

These are the currently available fields (may change in future releases):

  • Valid: Whether the license is valid. Note that a license may be expired and valid if the product release date is within the license expiration date.
  • LicenseKey: License key loaded from web.config or assigned to LicenseKey.
  • ProductName: Full name of the licensed product.
  • CustomerName: Name of the registered customer that owns the license.
  • ExpirationDate: Expiration date for the product free updates.

Retrieve the values either using a dynamic object or a property indexer:


string productName = Application.LicenseInfo.ProductName;
string customerName = Application.LicenseInfo["CustomerName"];

Static memberLicenseKey

String: Returns or sets the runtime server license key.

Setting the LicenseKey programmatically has to be done before the application is loaded. The best place is the static constructor for the Program static class, or the static constructor of the main window (if defined in Default.js).


static class Program
{
static Program()
{
Application.LicenseKey = "...";
}
}

Static memberMainPage

Page: Returns or sets the current full page window.

Static memberOpenForms

FormCollection: Returns a collection of open forms owned by the application.

Static memberOpenPages

PageCollection: Returns a collection of open pages owned by the application.

Static memberPlatform

ClientPlatform: The name of the currently loaded platform.

Static memberProductName

String: Returns the product name associated with this application.

Static memberProductVersion

String: Returns the product version associated with this application stored either in AssemblyInformationalVersionAttribute or AssemblyFileVersionAttribute.

Static memberQueryString

NameValueCollection: Returns the parameters used to launch the application.

Static memberRightToLeft

Boolean: Returns or sets whether all the controls in the applications should operate using the right-to-left mode.

The value of this property is updated automatically when the current language changes if the value of "rightToLeft" in the application configuration file is set to "auto".

Static memberRuntimeMode

Boolean: Returns true when the application is running in not in design, debug or test mode.

Static memberServerName

String: Returns the server's host name, DNS alias, or IP address as it would appear in self-referencing URLs.

Static memberServerPort

Int32: Returns the port number to which the request was sent.

Static memberServerVariables

NameValueCollection: Returns the server variables.

Static memberServices

ServiceProvider: Returns the ServiceProvider implementation used by Wisej.NET to manage Dependency Injection across the application. Since 3.1

Static memberSession

Object: Provides a generic storage for session-based objects.

Static memberSessionCount

Int32: Returns the total number of currently active sessions.

Static memberSessionId

String: Returns the unique current session ID.

Static memberShowConsole

Boolean: Shows or hides the debug console on the browser.

Displays a simple HTMl only debug console. Works with any browser also when the developer tools are not available.

Static memberShowLoader

Boolean: Returns or sets whether the browser is blocked by the Ajax loader.

Static memberStartupPath

String: Returns the root path of the web application.

Static memberStartupUri

Uri: Returns the URI used to start the application.

Static memberStartupUrl

String: Returns the URL used to start the application.

Static memberTheme

ClientTheme: Returns or sets the current ClientTheme.

You can create and modify a new custom theme using the ClientTheme class. The new theme can be based on an existing theme, can be empty, or can be initialized from a JSON string.


// create a new custom theme cloned from the current theme.
var myTheme = new ClientTheme("MyTheme", Application.Theme);

// alter the buttonFace color.
myTheme.Colors.buttonFace = "red";

// update the current session using the new custom theme.
Application.Theme = myTheme;

You may also alter a global theme shared by all sessions.



// change the buttonFace color in the current theme.
// if the theme is one of the global themes, i.e. it was loaded
// using Application.LoadTheme(name), then the change is also global.
Application.Theme.Colors.buttonFace = "red";

// since the theme objects are all dynamic and use a special DynamicObject
// class part of the Wisej Framework, you can also use a string indexer
// to address any field.
Application.Theme.Colors["buttonFace"] = "red";


Static memberTitle

String: Returns or sets the page title in the browser.

Static memberUri

Uri: Returns the current Uri used either to launch or reload the application. It may be different from StartupUri.

Static memberUrl

String: Returns the current URL used either to launch or reload the application. It may be different from StartupUrl.

Static memberUser

IPrincipal: Returns the security information for the current request.

Static memberUserAgent

String: Returns the raw user agent string of the client browser.

Static memberUserHostAddress

String: Returns the IP host address of the remote client.

Static memberUserHostName

String: Returns the DNS name of the remote client.

Static memberUserIdentity

WindowsIdentity: Returns the WindowsIdentity type for the current user.

Static memberUserLanguages

String[]: Gets a sorted string array of client language preferences.

Methods

Static memberAddEventFilter(filter)

Adds an event filter to monitor all the incoming events before they are routed to their respective component.

ParameterTypeDescription
filterIEventFilterAn object that implements the IEventFilter interface to add to the filter list.

Static memberAddTranslation(text, translation)

Adds the text and corresponding translation to the default locale on the client.

ParameterTypeDescription
textStringThe text to translate.
translationStringThe translation override.

Static memberAlertAsync(message)

Instructs the browser to display a dialog with an optional message, and to wait until the user dismisses the dialog.

ParameterTypeDescription
messageStringA string you want to display in the alert dialog.

Returns: Task. An awaitable Task that represents the asynchronous operation.

Static memberCall(function, args)

Executes the JavaScript function on the client.

ParameterTypeDescription
functionStringThe name of the function to execute.
argsObject[]The arguments to pass to the function.

Static memberCall(function, callback, args)

Executes the JavaScript function on the client and receives the return value (or null) in the callback method.

ParameterTypeDescription
functionStringThe name of the function to execute.
callbackAction<Object>Asynchronous callback method that receives the return value.
argsObject[]The arguments to pass to the function.

Static memberCallAsync(function, args)

Asynchronously executes the JavaScript function on the client and returns an awaitable Task with the result of the remote call.

ParameterTypeDescription
functionStringThe name of the function to execute.
argsObject[]The arguments to pass to the function.

Returns: Task<Object>. An awaitable Task that represents the asynchronous operation.

Static memberCancelFullScreen()

Cancels the fullscreen mode.

Static memberConfirmAsync(message)

Instructs the browser to display a dialog with an optional message, and to wait until the user either confirms or cancels the dialog. until the user dismisses the dialog.

ParameterTypeDescription
messageStringA string you want to display in the confirm dialog.

Returns: Task<Boolean>. An awaitable Task that represents the asynchronous operation.

Instance memberDispose()

Static memberDownload(filePath, fileName, ondownload)

Downloads the specified file on the client.

ParameterTypeDescription
filePathStringThe file to download.
fileName optionalStringThe name of the file to save on the client.
ondownload optionalAction<String>Optional callback invoked when fileName is downloaded.

Static memberDownload(image, fileName, ondownload)

Downloads the specified image to the client.

ParameterTypeDescription
imageImageThe image to download.
fileNameStringThe name of the file to save on the client.
ondownload optionalAction<String>Optional callback invoked when fileName is downloaded.

Static memberDownload(stream, fileName, ondownload)

Downloads the bytes in the stream to the client.

ParameterTypeDescription
streamStreamThe stream to send to the client.
fileNameStringThe file name the client will use to save the stream.
ondownload optionalAction<String>Optional callback invoked when fileName is downloaded.

Static memberDownloadAndOpen(target, filePath, fileName, ondownload)

Downloads the specified file on the client.

ParameterTypeDescription
targetStringSpecifies where to open the file. Leave empty or use "_self" to open in the current tab, _blank to open in a new tab.
filePathStringThe file to download.
fileName optionalStringThe name of the file to save on the client.
ondownload optionalAction<String>Optional callback invoked when fileName is downloaded.

Static memberDownloadAndOpen(target, image, fileName, ondownload)

Downloads the specified image to the client.

ParameterTypeDescription
targetStringSpecifies where to open the file. Leave empty or use "_self" to open in the current tab, _blank to open in a new tab.
imageImageThe image to download.
fileNameStringThe name of the file to save on the client.
ondownload optionalAction<String>Optional callback invoked when fileName is downloaded.

Static memberDownloadAndOpen(target, stream, fileName, ondownload)

Downloads the bytes in the stream to the client.

ParameterTypeDescription
targetStringSpecifies where to open the file. Leave empty or use "_self" to open in the current tab, _blank to open in a new tab.
streamStreamThe stream to send to the client.
fileNameStringThe file name the client will use to save the stream.
ondownload optionalAction<String>Optional callback invoked when fileName is downloaded.

Static memberEndPolling()

Stops the polling requests from the client.

Static memberEval(script)

Executes the JavaScript script on the client.

ParameterTypeDescription
scriptStringThe script to evaluate.

Static memberEval(script, callback)

Executes the JavaScript script on the client and receives the return value (or null) in the callback method.

ParameterTypeDescription
scriptStringThe script to evaluate.
callbackAction<Object>Asynchronous callback method that receives the return value.

Static memberEvalAsync(script)

Asynchronously executes the JavaScript script on the client and returns an awaitable Task with the result of the remote call.

ParameterTypeDescription
scriptStringThe script to evaluate.

Returns: Task<Object>. An awaitable Task that represents the asynchronous operation.

Static memberExit()

Terminates the application and the corresponding session.

Static memberFindComponent(match)

Find the first component that matches the conditions defined in the predicate function.

ParameterTypeDescription
matchPredicate<IWisejComponent>A custom Predicate expression used to match the IWisejComponent to find.

Returns: IWisejComponent. The first IWisejComponent qualified by the match expression.

This method lets an application find any live component in the current session.


// Find the first component that is a Button with Text = "OK"
var button = Application.FindComponent(c => c is Button && ((Button)c).Text == "OK");

Static memberFindComponents(match)

Finds all the components that match the conditions in the predicate function.

ParameterTypeDescription
matchPredicate<IWisejComponent>A custom Predicate expression used to match the list of IWisejComponent objects to find.

Returns: IList<IWisejComponent>. The list of IWisejComponent instances qualified by the match expression.

This method lets an application iterate through all the live components in the current session.


// List all text boxes that are read only in all forms.
var list = Application.FindComponents(c => c is TextBox && ((TextBox)c).ReadOnly);

Static memberGetInstance<T>(reference, builder)

Returns a session-static instance of T . Since 3.2.7

ParameterTypeDescription
TType of the singleton object.
reference by referenceSessionReference<T>Thread-static reference to the T singleton.
builder optionalFunc<T>Optional method for the creation of an instance of T .

Returns: T. The singleton instance of T associated with the current session.

This utility method simplifies the management of session-static (or session singleton) instances. It should be used to convert traditional static variables to session-static instances when changing an application designed for single users to a multi-user system. The code below shows how to use this feature together with the ThreadStaticAttribute to manage session-static instances and, at the same time, improve the speed of the code that relies on the singleton objects. Using the ThreadStaticAttribute backing field allows the code that retrieves the session-static instance to quickly check the last instance and compare the session id and avoid accessing the dictionary for every access within the same request. Otherwise the code would have to always store a local variable in order to speed up multiple operations using the same static field.



public class MyStatics {

// Thread-static singleton.
[ThreadStatic] private static SessionReference<MyStatics> _instance;

// Previously static fields (or properties).
public int Counter;

// Session singleton.
public MyStatics Instance
=> Application.GetInstance(ref _instance);

public static void DoSomething()
{
// was MyStatics.Counter++;
MyStatics.Instance.Counter++;
}
}


If the class a private constructor (to simulate a static class) or required initialization code or arguments, use the optional builder method:



public class MyStatics {

private MyStatics() { };

// Thread-static singleton.
[ThreadStatic] private static SessionReference<MyStatics> _instance;

// Previously static fields (or properties).
public int Counter;

// Session singleton.
public MyStatics Instance
=> Application.GetInstance(ref _instance, () => new MyStatics());

public static void DoSomething()
{
// was MyStatics.Counter++;
MyStatics.Instance.Counter++;
}
}

Static memberLoadAssembly(nameOrFile)

Loads an assembly given the file name or path.

ParameterTypeDescription
nameOrFileStringThe file name or full path for the assembly to load.

Returns: Assembly. The loaded Assembly.

This method loads the assembly and, if the assembly contains Wisej components that need embedded resources - like JavaScript classes or CSS styles - that are embedded in the assembly, notifies the client with the URL to load the additional resources dynamically.

Static memberLoadComponent(nameOrFile, className)

Creates an instance of the specified component from the assembly.

ParameterTypeDescription
nameOrFileStringThe file name or full path for the assembly to load.
classNameString

Returns: IWisejComponent. An instance of a Wisej component implementing the IWisejComponent interface.

Static memberLoadPackages(packages, callback)

ParameterTypeDescription
packagesIEnumerable<Package>
callback optionalAction<Boolean>

Static memberLoadPackagesAsync(packages)

ParameterTypeDescription
packagesIEnumerable<Package>

Returns: Task<Boolean>.

Static memberLoadTheme(name, mixins)

Changes the current theme.

ParameterTypeDescription
nameStringName of the theme resource. Use only the name without the path and without the extension.
mixins optionalString[]Optional list of theme mixins. If null, the default theme mixins are always applied.

Static memberMapPath(path)

Returns the full file path in relation to the application's project directory.

ParameterTypeDescription
pathString

Returns: String. The full path relative to the current application's root directory.

Navigate to the specified URL.

ParameterTypeDescription
urlStringURL to navigate to.
target optionalStringThe target browser window: _self, _blank, etc.

Navigate to the specified URL in a new browser tab and receive an optional callback when the tab is closed.

ParameterTypeDescription
urlStringURL to navigate to.
targetStringThe target browser window, cannot be _self and cannot be empty.
oncloseActionCallback function invoked when the browser tab is closed. Can be null.

Static memberOpenWindow(url, target, windowFeatures, onclose)

Opens the specified URL in a browser's popup window and receive an optional callback when the tab is closed.

ParameterTypeDescription
urlStringURL to navigate to.
targetStringThe target browser window, cannot be _self and cannot be empty.
windowFeaturesStringA string containing a comma-separated list of window features in the form name=value — or for boolean features, just name. These features include options such as the window's default size and position, whether or not to open a minimal popup window, and so forth.
oncloseActionCallback function invoked when the browser popup window is closed. Can be null.

Static memberPlay(type)

Plays one of the built-in sounds

ParameterTypeDescription
typeMessageBoxIconOne of MessageBoxIcon value that identifies the sound to play.

Static memberPlay(soundUrl)

Plays a sound.

ParameterTypeDescription
soundUrlStringA string representing either a sound file URL or a base64 data URL.

Static memberPost(callback)

Executes the callback method after all processing is completed and before updating the client.

ParameterTypeDescription
callbackActionMethod to invoke after the request has completed but before sending the response to the server.

The Post() method is similar to the BeginInvoke() method used by desktop applications. It allows you to execute a block of code out of sync with the current execution flow.



void Test() {

Application.Post(() => {
this.listBox.Items.Add("1");
});

this.listBox.Items.Add("2");

// The items will be added in this order: "2", "1".
}


Prints the specified control.

ParameterTypeDescription
controlIWisejControlThe control to print, can be a window, a page or a single control.

The control is printed without the caption or the borders, if present.

Static memberPrint()

Prints the entire browser window.

Static memberPromptAsync(message, defaultValue)

Instructs the browser to display a dialog with an optional message prompting the user to input some text, and to wait until the user either submits the text or cancels the dialog.

ParameterTypeDescription
messageStringA string of text to display to the user.
defaultValue optionalStringAn optoional string containing the default value displayed in the text input field.

Returns: Task<String>. An awaitable Task that represents the asynchronous operation.

Static memberRefreshSessionId()

Generates a new session id without losing the session. Since 3.5.2

Use this method after a successful login to prevent potential session fixation attacks.

Static memberReload()

Causes the application to reload on the browser.

Static memberRemoveEventFilter(filter)

Removes the filter from the list of registered event filters.

ParameterTypeDescription
filterIEventFilterAn object that implements the IEventFilter interface to remove from the filter list.

Static memberRequestFullScreen()

Requests the browser to enable fullscreen mode if supported.

Static memberRunInContext(context, action)

Executes the callback in context.

ParameterTypeDescription
contextIWisejComponentThe application context to update. It can be any Wisej component or the IWisejComponent returned by the property Current.
actionActionFunction to execute in context. The code in the function can access all the static Application properties when executed from an out-of-bound thread.

Static memberSetInstance<T>(reference, instance)

Replaces the object assigned to a session-static singleton. Since 3.5.2

ParameterTypeDescription
TType of the session-static object.
reference by referenceSessionReference<T>Thread-static reference to the T singleton.
instanceTNew value to assign to the session-static storage.

Static memberSetSessionTimeout(seconds)

Sets the current session timeout in seconds.

ParameterTypeDescription
secondsInt32

Static memberStartPolling(interval)

Instructs the client to start polling the server for UI changes at the specified interval when a WebSocket connection is not available.

ParameterTypeDescription
intervalInt32Polling interval in milliseconds. The minimum is 1000ms.

Calling this method when IsWebSocket is true has no effect. Use client side polling when you know that your code will start a background task that needs to update the client asynchronously (push updates) and your server or clients don't support WebSocket connections. Once the background tasks are completed call EndPolling to reduce the incoming requests from the client.



// this has not effect when the client and server are connected using WebSocket.
Application.StartPolling(1000);

Application.StartTask(() => {

for (int i = 0; i < 100; i++) {
this.label1.Text = "Counting..." + i;
Thread.Sleep(1000);
}

// this has not effect when the client and server are NOT connected using WebSocket.
Application.Update(this);

// this has not effect when the client and server are connected using WebSocket.
Application.EndPolling();

});

Throws:

Static memberStartTask(action)

Starts a new task within the current application context and returns immediately. See also background-tasks.

ParameterTypeDescription
actionActionStart method invoked by the new task when it starts up.

Returns: Task. An awaitable Task.

The task runs in the background but it's still capable of updating the client asynchronously when working with WebSocket by calling the Update method to push the UI updates to the client browser. If you want to support background updates for clients or servers that can't use the WebSocket connection, you can either add a Timer component to the parent container to force period requests to the server, or you can use the StartPolling and EndPolling methods.


Application.StartTask(() => {

for (int i = 0; i < 100; i++) {

this.label1.Text = "Counting..." + i;

// just wait a bit or it's too fast.
Thread.Sleep(1000);
Application.Update(this);
}
});

Static memberStartTask<T>(action)

Starts a new task with a return value within the current application context and returns immediately. See also background-tasks.

ParameterTypeDescription
T
actionFunc<T>Start method invoked by the new task when it starts up.

Returns: Task<T>.

The task runs in the background but it's still capable of updating the client asynchronously when working with WebSocket by calling the Update method to push the UI updates to the client browser. The generics overload of StartTask allows the task to return a value. You can use this with the async/await pattern and asynchronously wait for the task to complete. If you want to support background updates for clients or servers that can't use the WebSocket connection, you can either add a Timer component to the parent container to force period requests to the server, or you can use the StartPolling and EndPolling methods.


string text = await Application.StartTask(() => {

string value = "";
for (int i = 0; i < 100; i++) {

value += i.ToString();

// just wait a bit or it's too fast.
Thread.Sleep(100);
}
return value;
});

this.label.Text = text;
Application.Update(this);


Note that you don't have to specify the type in the angular brackets, the compiler will automatically detect the type from the return value of the asynchronous function.

Static memberStartTimer(dueTime, period, callback)

Starts a Timer bound to the current session context.

ParameterTypeDescription
dueTimeInt32The amount of time, in milliseconds, to delay before invoking the callback .
periodInt32The time interval between invocations, in milliseconds.
callbackActionA callback method to invoke at the specified intervals.

Returns: Timer. An instance of Timer.

You must save a reference to the returned Timer or the Garbage Collector will stop and dispose the timer. To alter the invocation period user Timer.Changer(), or stop the timer simply use Timer.Dispose(). See system.threading.

Static memberUpdate(context, action)

Executes the optional callback in context and pushes all the pending updates to the client when in WebSocket mode.

ParameterTypeDescription
contextIWisejComponentThe application context to update. It can be any Wisej component or the IWisejComponent returned by the property Current.
action optionalActionFunction to execute in context. The code in the function can access all the static Application properties when executed from an out-of-bound thread.

Use this method when you need to update the client asynchronously from an out-of-bound thread (different thread, not originating from a client request). You can call this method at the end of the code that updates the UI:


Application.StartTask(() => {

for (int i = 0; i < 100; i++) {

this.label1.Text = "Counting..." + i;

// just wait a bit or it's too fast.
Thread.Sleep(1000);
}

Application.Update(this);

});

Or you can use the optional action function to enclose the code that updates the UI in a block and ensure that the client is updated when the code block exits:


Application.StartTask(() => {

Application.Update(this, () => {

for (int i = 0; i < 100; i++) {

this.label1.Text = "Counting..." + i;

// just wait a bit or it's too fast.
Thread.Sleep(1000);
}
});

});

Events

Static memberActiveWindowChanged

EventHandler Fired when the active window changes.

Static memberApplicationExit

EventHandler Fired when the application is about to shut down.

Static memberApplicationRefresh

EventHandler Fired when the application is reloaded in the browser because the user hit refresh or changed the URL.

Static memberApplicationStart

EventHandler Fired when the application is started, after the Main method is called.

Static memberBeforeInstallPrompt

EventHandler Fired when the browser fires the "beforeinstallprompt" event. Corresponds to BeforeInstallPromptEvent.

Static memberBeginRequest

RequestEventHandler Fired at the beginning of every request.

Static memberBrowserSizeChanged

EventHandler Fired when the user resizes the browser.

Static memberBrowserTabActivated

EventHandler Fired when the user activates the browser tab.

Static memberBrowserTabDeactivated

EventHandler Fired when the user deactivates the browser tab.

Static memberCultureChanged

EventHandler Fired when the CurrentCulture changes.

Static memberEndRequest

RequestEventHandler Fired at the end of every request.

Static memberFocusedControlChanged

EventHandler Fired when the focused control changes.

Static memberHashChanged

HashChangedEventHandler Fired when the hash part of the URL changes on the client side.

Static memberIdle

EventHandler Fired when the current thread has completed processing all the events and before the response is sent back to the client.

Static memberImpersonationBegin

HandledEventHandler Fired right after ThreadBegin, only when Impersonate is set to true, to allow user code to take over the thread impersonation operations.

Set e.Handled to true if your application takes care of impersonation; otherwise false to let the default implementation attempt to impersonate the user. This event is not related to a session. It is best to attach to this event from a static type initializer, otherwise each listener will be called for every thread, regardless of the session. The default implementation in Wisej.NET is supported only in .NET Framework and the Windows platform.

Static memberImpersonationEnd

HandledEventHandler Fired at the end of every request when impersonation is enabled in the JSON configuration file.

Set e.Handled to true if your application takes care of impersonation; otherwise false to let the default implementation attempt to impersonate the user. This event is not related to a session. It is best to attach to this event from a static type initializer, otherwise each listener will be called for every thread, regardless of the session. The default implementation in Wisej.NET is supported only in .NET Framework and the Windows platform.

Static memberLicenseError

LicenseErrorEventHandler Fired when a license error occurs.

Static memberResponsiveProfileChanged

ResponsiveProfileChangedEventHandler Fired when the active responsive profile is changed.

Static memberRightToLeftChanged

EventHandler Fired when the RightToLeft value changes.

Static memberSessionTimeout

HandledEventHandler Fired when the session is about to time out.

The default behavior built-in Wisej is to display a dialog asking the user to prolong the session. Set Handled to true to stop the default behavior.

Static memberThemeChanged

EventHandler Fired when the current theme is changed.

Static memberThreadException

ThreadExceptionEventHandler Fired when a thread exception is thrown.

Implements

NameDescription
IWisejComponentAll wisej components implement this interface.