-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhook events when unloading addin #54
Comments
I have noticed this issue as well. Luckily we keep the add-in always enabled / loaded, so this isn't really a problem for us. |
Can you provide some sample code/add-in? |
I finally made an example: https://github.com/brinkdinges/solidworks-api-events-example/commits/master It shows an popup every time the active model info changes. When you load the add-in, then unload it, the popup still shows up. It's only not shown when the last document is closed. |
I've been looking into this issue again and I think we shouldn't try to solve it in SolidDna. I assume most add-ins will use the ActiveModelInformationChanged event or one of the other events in SolidWorksApplication. We cannot clear the InvocationList for these events, because multiple add-ins might use SolidDna and we would have to remove certain events. We also don't know anything about their WPFControl, so we cannot set the DataContext to null or something like that (if that would even unhook the events). I have solved it for my add-in by storing the task pane view model instance. When DisconnectedFromSolidWorks is called, I call a ShutDown method on the instance to unsubscribe from the events. Edit: example here, commit 7801685 |
Hi guys,
My add-in for creating a new drawing with one click uses events, for example when the active model changes, to show a different panel in the task pane. I have noticed that these events stay hooked after the add-in is unloaded.
Is this behavior expected? What would be the best way to unhook from these events? I already tried:
Any ideas how to best handle this?
The text was updated successfully, but these errors were encountered: