Skip to main content
RSS feed Subscribe to feed


Creating Threads

Threading is used when some work needs to be performed asynchronously. Properly used it may enhance the end user experience considerably, but it also requires a fair amount of work, so it is only recommended for scenarios where it will make a difference.


The following cases are examples when the use of threading makes sense.

Virtual Columns and Image Rendering

From Spotfire 2.2, the TablePlot supports virtual columns and image rendering. Both features are characterized by on-demand work and result caching. A request for a value/image is either successful (the value existed in a cache), or else a work item is created and dispatched.

When the work item is completed, it is added to the cache and the caller is informed that the value is available. The caller then typically invalidates the UI, which will trigger a request for the value.

Custom Visualization Rendering

Since rendering many data points can be slow, it is a good idea to perfom rendering on a background thread. This can be accomplished by creating a custom worker class and factory that has the custom visualization as its WorkerModel. Also create a custom work item with a size property and a result image. The worker would then take the size and the visualization model and produce an image as result. The UI for the visualization would then create a WorkDispatcher for the worker and send it work items with correct size. When work items are received, the image is stored and the control is invalidated (using ApplicationThread.InvokeAsynchronously since the callback is from the worker thread).

Background Information and Example

  • Threading Framework
    The threading framework enables the use of asynchronous calling. It is useful when a background thread is used to fetch data, perform calculation, performing custom value rendering, or even have custom visualizations render on a the background thread.
  • How to Create a Thread
    This example describes a simple thread implementation.