Home Forums Software Development dev Multiple WPF Windows: Should every window declare own Host?

This topic contains 5 replies, has 2 voices, and was last updated by  Grant [Tobii] 3 months, 2 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #11863

    Tobias Kozlowski
    Participant

    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

    #11867

    Grant [Tobii]
    Moderator

    Hi @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.

    #11869

    Tobias Kozlowski
    Participant

    Thank 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

    #11870

    Grant [Tobii]
    Moderator

    Hi @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.

    #11874

    Tobias Kozlowski
    Participant

    In 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.

    #11917

    Grant [Tobii]
    Moderator

    Indeed, 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.

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.