Home › Forums › Software Development › Multiple WPF Windows: Should every window declare own Host?
Tagged: Virtual window interactor WPF
- This topic has 5 replies, 2 voices, and was last updated 5 years ago by Grant [Tobii].
- AuthorPosts
- 09/08/2019 at 23:58 #11863Tobias KozlowskiParticipant
I have a program that can create multiple wpf windows. And i want every one of them to contain a virtual window. Should i declare these variables in every one of the wpf windows?
private Host host = new Host();
private VirtualWindowsAgent virtualWindowsAgent;
VirtualWindowBase myFreeFloatingWindow;
VirtualInteractorAgent virtualAgent;Or is it a waste of ressources?
Tobias
12/08/2019 at 14:27 #11867Grant [Tobii]KeymasterHi @eyetrackjack and thanks for your query. There is no need to declare for each WPF window instance as we recommend you use a single host + agent per application. Therefore make the declaration within the main method.
Declaring multiple instances may have unpredictable consequences so please refrain from doing so.
Please do let us know if you are having any issues in this regard or if we can provide further information.
12/08/2019 at 17:23 #11869Tobias KozlowskiParticipantThank you for the answer.
It is a WPF application and i don’t use a main routine. So, do i declare it in app.xaml.cs and access it like this?
(App.Current as App).Host
13/08/2019 at 18:14 #11870Grant [Tobii]KeymasterHi @eyetrackjack, the Main() Entry point should be located within App.Xaml.Cs -> App -> Main():Void which you can find within the Solution Explorer of Visual Studio and is automatically generated whenever a new WPF project is generated in VS. Here you go declare the Host variables. Hopefully should be clear know, please let me know otherwise.
13/08/2019 at 20:56 #11874Tobias KozlowskiParticipantIn the examples there is always a OnStartUp and OnExit routine. In the example here https://github.com/Tobii/CoreSDK But it doesn’t show how to access the host from a different window. Ok, it is not necessary there. I will look for different examples.
21/08/2019 at 21:06 #11917Grant [Tobii]KeymasterIndeed, there are a few different options for the entry point including both the void:main() and OnStartup Routines, however so long as the Tobii host (and other relevant variables) is declared, there should be no difference to program functionality.
Please do let us know if we can provide any further information. Best Wishes.
- AuthorPosts
- You must be logged in to reply to this topic.