Reputation: 97
I have a WPF MVVM app. It has a View and relevant ViewModel. ViewModel has an ObservableCollection of SerialPorts. Closing each port takes few seconds. Now I close my app just hitting the 'X' button - and if I use app.OnExit - my ViewModel is already disposed. When debugging - this sometimes gives me all sorts of compiler's strange behaviors, I give up trying to understand/fix them all.
On app's close/exit - how can I call some method in my ViewModel, to close all ports (which can take minutes), and do some other cleanup?
Upvotes: 2
Views: 1774