Rhino C# How to run code on rhino closing?

Hi there, I’m writing a plugin which requires some files to be saved when rhino closes. I assume I’d need to catch the closing RhinoApp event somehow, could anyone show me how to do this?

I’ve found this link while doing research about this, but I’'m not sure how to actually catch this event :confused:

https://developer.rhino3d.com/api/RhinoCommon/html/E_Rhino_RhinoApp_Closing.htm

The plugin class has “OnLoad” and “OnShutDown”
Just override those function in the main class from your plugin - this might do what you need ?

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_PlugIns_PlugIn_OnShutdown.htm

if you want to use RhinoApp.Closing event:
in c# you can subscribe with the += symbol and unsubscribe with -= symbol:

does this help ? kind regards - tom

1 Like

This was super helpful! Both of these solutions fix my issue perfectly.

Thanks for the help!