Repaintable canvas to show Cognex camera image

An async script is any script function that is executed via system.util.invokeAsynchronous(). I generally prefer to place such functions in project script modules, but they can also be defined in-line (nested) in another script. Java Swing (the base for Vision) is single-threaded. Component events in Vision are really Java Swing events and run on the Swing GUI thread. Running time-consuming code in a component event freezes the GUI. That would include code that sleeps or waits on the network or the filesystem. Don't do it.

However, running in a background thread has some limitations, too. Since Swing is single-threaded, it is full of operations on components that are unlocked. You can get away with manipulating components from a background thread for a long time, but eventually you'll corrupt a component and crash Vision. Not just locked up. Dead. Passing data back to Swing requires using system.util.invokeLater().

See these topics for many details: