algorithmic modeling for Rhino

Hi All,

I'm currently doing some experiments with grasshopper in C# components (the kind that inherits GH_ScriptInstance) that involve events and other code that may or may not simply stop existing when a component gets deleted, or is recompiled, leaving some ugly on the loose threads or events hanging around.

Is there an equivalent of the Dispose() method inside a C# block, or something to hook onto when the component gets recompiled, deleted or other behaviour that should make sure it will stop existing from there on out, so I can make sure the component can clean up after itself?


Views: 499

Replies to This Discussion

Not really. I know it's very annoying, but there's no good solution to this.


David Rutten

Would be out of the question to add something like a Dispose() method?


Otherwise: my workaround now is to watch the enabled property of the component, and disable it before recompiling:

if (Component.IsLocked) {
// time to clean up the mess

I'll have a long look at all the situations where custom code becomes stale, it's probably possible to add two overridable functions (one for disabling, one for enabling).


David Rutten






  • Add Photos
  • View All


  • Add Videos
  • View All

© 2021   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service