Dependency Injection and the ActionEventHandler Lifetime #14
-
I'm wondering if there may be a best practice for the ActionEventHandler and it's lifetime. I am able to add a singleton to the Host and retrieve that service in each ViewModel that needs it. On the surface all seems well, however, I'd love to hear if this is acceptable or not. Other examples I've found using the RevitToolkit seem to create a new instance of the ActionEventHandler when the private field is declared, or when the ViewModel is constructed. If the Host is even suitable for the ActionEventHandler, this leads me to believe adding the handler as transient might be better. Any input is greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
it can be Singleton. The only problem is exceptions. If you don't handle exceptions in the catch block, Revit will unload this EventHendler and it will become unusable |
Beta Was this translation helpful? Give feedback.
it can be Singleton. The only problem is exceptions. If you don't handle exceptions in the catch block, Revit will unload this EventHendler and it will become unusable