Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Scripting_function


Panel
titleDescription

This is an advanced scripting function. Invokes (calls) the given Python function on a different thread. This means that calls to  invokeAsynchronous will return immediately, and then the given function will start executing asynchronously on a different thread. This is useful for long-running data intensive functions, where running them synchronously (in the GUI thread) would make the GUI non-responsive for an unacceptable amount of time.

Under no circumstances should you ever do anything in the function that is invoked asynchronously that
Warning
titleWarning!
Caution_friendly

This function should not be used to asynchronously interacts with the GUI in Vision. This means things like interacting with window navigation, setting and getting component properties, showing error/message popups, etcand really any other methods that can interact with components and windows. If you need to do something with the GUI in Vision with this function, this must be achieved through a subsequent call to system.util.invokeLater.

By contrast, this function is safe to use in the gateway, which also means calls from Perspective are safe. 

Panel
titleClient Permission Restrictions

This scripting function has no Client Permission restrictions.

Panel
titleSyntax

system.util.invokeAsynchronous(function, [args], [kwargs], [description])

  • Parameters

PyObject function A Python function object that will get invoked with no arguments in a separate thread.

Iterable args - A list or tuple of Python objects that will be provided to the called function as arguments. Equivalent to the * operator. [optional]. Added in 8.0.15.

Dictionary kwargs - A dictionary of keyword argument names to Python object values that will be provided to the called function as keyword arguments. Equivalent to the ** operator. [optional]. Added in 8.0.15.

String description - A description to use for the asynchronous thread. Will be displayed on the current scope's diagnostic view for scripts. For Vision and the Designer, this would be the "Scripts" tab of the Diagnostics popup. For Perspective and the Gateway scope, this would be the Gateway's Running Scripts status page [optional]. Added in 8.0.15.

  • Returns

Thread - The executing Thread.

  • Scope

Gateway, Vision Client, Perspective Session

Panel
titleCode Examples
Code Block
languagepy
titleCode Snippet
# This code would do some data-intensive processing, and then call
# back to the GUI to let it know that it is finished.
# We use default function parameters to pass the root container into these
# functions. (See a Python reference if you don't understand this)
 
def longProcess(rootContainer = event.source.parent):
   import system
   # Do something here with the database that takes a long time
   results = ...( something )
   # Now we'll send our results back to the UI
   def sendBack(results = results, rootContainer = rootContainer):
      rootContainer.resultsProperty = results
   system.util.invokeLater(sendBack)
   
system.util.invokeAsynchronous(longProcess) #Note that this is 'longProcess' instead of 'longProcess()'
Panel
titleKeywords

system util invokeAsynchronous, util.invokeAsynchronous