Home › Forums › Software Development › _host.Dispose() hangs and application does not shutdown clearly
Tagged: dispose WPF MVVM
- This topic has 3 replies, 2 voices, and was last updated 5 years, 6 months ago by
Yann Gagnon.
- AuthorPosts
- 14/03/2018 at 17:36 #8000
Yann Gagnon
ParticipantHi all,
You’ll have to forgive me, I’m not a software developer, though I do have some programming experience.I’ve gone through many of the examples, but I’m implementing the eye tracking a little bit differently since I wish to use the MVVM architecture and I’m using Caliburn Micro to help that along.
I created a new class as a Model (as per the MVVM convention) which contains both a host and a wpfinteractor as properties, and it has an OnExit method to Dispose the host. I create an instance of the model in the ViewModel (again MVVM). The problem is that Dispose hangs. However, if I call OnExit during the construction of the ViewModel(), then the method OnExit runs host.Dispose properly and all is good.
I’ve inspected my Model with a breakpoint, and the host appears to be a complete object, with an Id and everything. I’m at a lost why running OnExit within the ViewModel() constructor works, while it hangs when calling OnExit elsewhere. Again, the method is accessed, I have some dummy output to verify it, but it hangs at host.Dipose(). I should also note that I can get the eye tracking to work and output the gaze stream to the output window. The problem persists with or without any access to gaze stream data.
I would appreciate any enlightenment!
14/03/2018 at 23:26 #8001Yann Gagnon
ParticipantUpdate: I got it to work quickly by implementing a Stop Eye Tracker button and linking it to a method. My feeling is that the order of things shutting down was the culprit. Still hoping to implement a more robust solution.
16/03/2018 at 10:24 #8007Grant [Tobii]
KeymasterHi @yanngagnon, thanks letting us know and glad you figure the solution. Indeed you will need to stop tracking in this instance and be careful of the order but I will pass along your comments to developers who may be able to provide you with an alternative if appropriate.
May I ask specifically what flavour of the Tobii Core SDK you are running? I think it would be great if you could share some of your project when possible for any other users interested in MVVM Architecture.
16/03/2018 at 20:25 #8013Yann Gagnon
ParticipantHi @Grant. I’m using the Interaction API in VS17.
What I’ve done is installed Caliburn Micro (lots of tutorials online), which makes it easier to set up an MVVM architecture, but relies on naming conventions.
- AuthorPosts
- You must be logged in to reply to this topic.