Is there a way to access to viewmodel from MainWindow.cs? #4447
-
I am currently developing an app on WPF platform with a serial port connection. Currently using the MVVMCross 8.0.2 version. In the app a receiver thread always listens the serial port for incoming data inside an infinite loop. When the application is closed thread continous to work and application doesnt stop. I am trying to solve this problem for a while, what i've tried so far is using the view appear/disappear functions, however, these functions are not called when the app is closed by the window close button. So, i thought if i can access to viewmodels from the mainwindow.cs, i can stop the thread using the window_closing event. Is there a way to do that? Or if you have any different idea to stop the thread when the app is closed, i would appreciate the help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Sounds like you are doing some weird stuff in your ViewModel and it has the responsibility for listening to your serial port socket. This should probably be offloaded to a service layer in your App instead. Then you could resolve this service layer part using the IoC. |
Beta Was this translation helpful? Give feedback.
Sounds like you are doing some weird stuff in your ViewModel and it has the responsibility for listening to your serial port socket. This should probably be offloaded to a service layer in your App instead. Then you could resolve this service layer part using the IoC.