BackgroundWorker.instance_by_component
- classmethod BackgroundWorker.instance_by_component(ghenv, long_running_function=None, dispose_function=None, auto_set_done=True, force_new=False, args=())[source]
Get the worker instance assigned to the component.
This will get a persistant instance of a background worker for a given component. The parameter force_new can be set to True to request a new instance to be created.
- Parameters:
- ghenv
GhPython.Component.PythonEnvironment
Grasshopper environment object
- long_running_functionfunction, optional
This function will be the main entry point for the long-running task.
- dispose_functionfunction, optional
If defined, this function will be called when the worker is disposed. It can be used for clean-up tasks and resource deallocation.
- auto_set_donebool, optional
If true, the worker state will be automatically set to
Done
after the function returns. Defaults toTrue
.- force_newbool, optional
Force the creation of a new background worker, by default False.
- argstuple, optional
List or tuple of arguments for the invocation of the
long_running_function
. Defaults to()
.
- ghenv
- Returns:
BackgroundWorker
Instance of the background worker of the current component.