Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

NavigationManager stops sworking after closing and opening the app without terminating the process blazor #106

Open
eivarin opened this issue May 1, 2020 · 1 comment

Comments

@eivarin
Copy link

eivarin commented May 1, 2020

The navigation manager stops working after closing and opening the app. I'm using a windows forms notify icon and a custom application context to keep the process open even if the webwindow is closed but then when I go to reopen the webwindow under the same process it opens normally in the page that I was previously, but when i go to click a div that triggers a NavigationManager.NavigateTo(LinkName); it doesn't change page.
I tried to debug this and, when I clicked a div that changes the page before closing it did this:
image
then this
image
and then run something with the dispatcher which looks to be made for error checking.
After closing and reopening the webwindow I try to clicks a div that changes the page it did the same thing again but then when i clicked it again it didnt even debugged anymore. Note that while the buttons did nothing the HTML and css still worked as the hovers where still working

@eivarin
Copy link
Author

eivarin commented May 1, 2020

So i managed to fix this, but since it isn't a general bug just one very specific for me I won't make a PR for it.
The problem was the instance of DesktopNavigationManager was being kept the same between opening and closing the webwindow..... what I did was:

In the DesktopNavigationManager.cs I removed the protection from the instance:
from this
public static readonly DesktopNavigationManager Instance = new DesktopNavigationManager();
to this
public static DesktopNavigationManager Instance = new DesktopNavigationManager();

and added a line that creates a new instance for DesktopNavigationManager whenever the application closes:

try{
                    WebWindow.NavigateToUrl(BlazorAppScheme + "://app/");
                    WebWindow.WaitForExit();
}
finally{
                    appLifetimeCts.Cancel();
                    //my code
                    DesktopNavigationManager.Instance = new DesktopNavigationManager();
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant