xcad
xcad copied to clipboard
Event can not be released
It's a addin application for solidworks, which contains a wpf window with the viewmodel . In the viewmodel, I add two events by using the below code:
application.Documents.Active.Selections.NewSelection += Selections_NewSelection;
application.Documents.Active.Selections.ClearSelection += Selections_ClearSelection;
And another function which is getDoc method in the viewmodel, I use the linq statements to get the doc:
var doc = application.Documents.First(x => x.Title.Contains(name));
In the viewmodel.dispose() method, it will release the event:
application.Documents.Active.Selections.NewSelection -= Selections_NewSelection;
application.Documents.Active.Selections.ClearSelection -= Selections_ClearSelection;
The viewmodel.dispose() method would been called by wpf window_Closed method. The issue is: After I using the getDoc method, then closed the window, the events never been released. It always be called until I closed the solidworks application.