Running code when a Grasshopper component is deleted?


I have created a Grasshopper component that uses an Xbox controller as input. I have created an XboxController class which creates a new thread responsible for polling the controller. I’d like to run code when my Grasshopper component is deleted to stop the thread, but I cannot find anything that would allow me to accomplish this.

The reason I’d like to do this is that my thread only exits when the controller is disconnected (I have a while loop to accomplish this) and I would like it to also stop if the component is deleted.

Thank you,

1 Like