• processAsync ?-tag str? ?-priority (1-4)? task ?notification?
This is an experimental command to process some pieces of code
asynchronously on a separate thread. The task argument is a Tcl
proc to execute asynchronously: the command schedules the task and returns
immediately. The notification argument is optional: it specifies
the name of another proc to invoke when the task completes successfully.
In case a notification proc is specified, one may also
specify a -tag option in order to identify the task: its value can
be any token and will be passed as an argument in the notification proc.
The -priority option indicates the priority of the
scheduled task. Its value is an integer between 1 and 4 (the default is 3)
with the following meaning:
1 | background priority |
2 | low priority |
3 | default priority |
4 | high priority |
Caveats:
- The task being run asynchronously, great care must be taken in order
to avoid concurrent access to global variables.
- Because it is executed on a secondary thread, the task must not invoke
any command involving the user interface. In particular, it must not open
windows, or write messages in the status bar, or display dialogs etc.
otherwise the application will crash.
- The notification proc, on the contrary, is executed on the main thread, so it may
invoke commands using the user interface.