Scripting Resources for DigitalMicrograph™

banner

Dave Mitchell's DigitalMicrograph™ Scripting Website

Home | Scripts | Examples | Functions | Recent Updates | Tutorials | Resources | Publications | Consulting | Projects | Contact & Bio |PyJEM| Search

 

Example: Running a Thread from with a Dialog
Function

Example code which shows how to run a dialog class method as a thread. Control of the thread and access by the thread to the dialog elements/values is then simple. A second example shows how to run a thread from a dialog, with a seperate thread class.

Version
version:20130828, v1.0
Author
D. R. G. Mitchell
Acknowledgements
Vincent Hou suggested this very convenient way of running threads from within a dialog.
Comments
The thread is simply a Dialog class method. It runs like any other dialog function, but being a thread, it runs in background. This is useful for things like accessing cameras or any lengthy or periodic task, as DM is still accessible while the thread is running.
System Requirements
Should be compatible with all recent versions of DigitalMicrograph, but only tested on GMS 2.11 (XP).
Known Issues
Since the thread is running within the dialog, when the dialog is closed and goes out of scope, an exception terminates the thread. This means that closing the dialog will stop the thread. In the example mentioned above this is not the case. This means that this method can be used safely with threads which run indefinitely, until the dialog sends them a stop signal.
Supported
Yes
Included Files
Main script file.
Source Code

See attached script