Click or drag to resize

Synchronization

Thread synchronization is very important in Wisej due to its Real Time nature and the small frequent WebSocket communication with the server. Understanding the basics of Wisej synchronization helps when dealing with long running actions, or parallel background tasks that need to interact with the user interface.

Synchronization Pattern

All events from the client are synchronized. Wisej will always execute only one client event at a time in the order they are received from the client.

Note Note

If the server takes a long time to process an event, the client may show a gif loader mask blocking the user from interacting with the application. The timing, loader image, and other properties are configurable in Default.json and in the theme.

Refresh requests are not synchronized with the session and are processed in parallel. The user can refresh the browser while the server is processing an event and reload the page at any time.

Data loading requests (datagrid pulling rows, listview pulling items) are not synchronized with the session and are processed in parallel. However they need to lock the collection they are rendering. This feature allows a user to refresh the browser while the server is processing an action and receive back the entire appliaction.

All collections in Wisej are now synchronized at the collection level. It's the tightest possible locking and avoids any possibility of deadlocks since there are no external events in the locked blocks.

Background tasks that need to alter a collection of components owned by a control (i.e. Rows, Items, Child Controls, etc.) may lock the collection itself. Wisej uses the collection instance as the SyncRoot object.

Fair Locking

Usually thread locks are not guaranteed by the OS to be released in the order they are acquired. Wisej uses a special implementation of the "Fair Locking" pattern to guarantee that the threads are relesed in the order they are received and that if a component is disposed while waiting for the server to process its events the execution is aborted.

Background Tasks

If your application runs background tasks that interact with UI controls, remember to check if the control has been disposed and lock the collections your are manipulating. If the user closes the application, or the parent of a control, the control is disposed and your background task may generate an exception.

In general, the synchronization of your application is entirely up to you, like in any other system. Wisej can only guarantee the synchronization of its internal functions.

See Also