From 9092b764ec0daab01cb631e7a7788254f543148e Mon Sep 17 00:00:00 2001 From: Robert Haken Date: Thu, 12 Dec 2024 13:23:57 +0100 Subject: [PATCH] [Blazor] Lazy loading - Complete example - Prevent repeated loads (#34243) --- aspnetcore/blazor/webassembly-lazy-load-assemblies.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aspnetcore/blazor/webassembly-lazy-load-assemblies.md b/aspnetcore/blazor/webassembly-lazy-load-assemblies.md index a89174db8f..a0054cb667 100644 --- a/aspnetcore/blazor/webassembly-lazy-load-assemblies.md +++ b/aspnetcore/blazor/webassembly-lazy-load-assemblies.md @@ -592,16 +592,18 @@ The assembly is assigned to lazyLoadedAssemblies = new(); + private bool grantImaharaRobotControlsAssemblyLoaded; private async Task OnNavigateAsync(NavigationContext args) { try { - if (args.Path == "robot") + if ((args.Path == "robot") && !grantImaharaRobotControlsAssemblyLoaded) { var assemblies = await AssemblyLoader.LoadAssembliesAsync( new[] { "GrantImaharaRobotControls.{FILE EXTENSION}" }); lazyLoadedAssemblies.AddRange(assemblies); + grantImaharaRobotControlsAssemblyLoaded = true; } } catch (Exception ex) @@ -644,16 +646,18 @@ The assembly is assigned to lazyLoadedAssemblies = new List(); + private bool grantImaharaRobotControlsAssemblyLoaded; private async Task OnNavigateAsync(NavigationContext args) { try { - if (args.Path == "robot") + if ((args.Path == "robot") && !grantImaharaRobotControlsAssemblyLoaded) { var assemblies = await AssemblyLoader.LoadAssembliesAsync( new[] { "GrantImaharaRobotControls.{FILE EXTENSION}" }); lazyLoadedAssemblies.AddRange(assemblies); + grantImaharaRobotControlsAssemblyLoaded = true; } } catch (Exception ex)