public static IWebAssemblyHost InitializeApplicationServices(this IWebAssemblyHost webhost) { if (webhost == null) { throw new ArgumentNullException(nameof(webhost)); } var serviceProvider = webhost.Services; var applicationServiceManager = serviceProvider.GetService <ApplicationServiceManager>(); if (applicationServiceManager != null) { async Task InitializeApplicationServicesAsync() { await applicationServiceManager .InitializeApplicationServicesAsync(serviceProvider, cancellation : default) .ConfigureAwait(false); // Forces an asynchronous yield to the continuation that blocks synchronously // We do not want the contiuations of applicationServiceManager.InitializeApplicationServicesAsync to be blocked indefinitely await Task.Yield(); } // We cannot wait for the result currently, as this blocks the JsRuntime to be initialized that we need in the app-services. // https://github.com/AI4E/AI4E/issues/39 InitializeApplicationServicesAsync() .ConfigureAwait(false) //.GetAwaiter() //.GetResult() ; } return(webhost); }
public static void Main(string[] args) { IWebAssemblyHost host = CreateHostBuilder(args).Build(); host.Run(); serviceProvider = host.Services; }
public static void Main(string[] args) { Cshtml5Initializer.Initialize(); IWebAssemblyHost host = CreateHostBuilder(args).Build(); host.Run(); host.Dispose(); Application.RunApplication(() => { var app = new CSHTML5.Samples.Showcase.App(); }); }
public static void Main(string[] args) { Cshtml5Initializer.Initialize(); IWebAssemblyHost host = CreateHostBuilder(args).Build(); host.Run(); host.Dispose(); Application.RunApplication(() => { var app = new OpenSilverApplication1.App(); }); }
/// <summary> /// Runs the application. /// </summary> /// <param name="host">The <see cref="IWebAssemblyHost"/> to run.</param> /// <remarks> /// Currently, Blazor applications running in the browser don't have a lifecycle - the application does not /// get a chance to gracefully shut down. For now, <see cref="Run(IWebAssemblyHost)"/> simply starts the host /// and allows execution to continue. /// </remarks> public static void Run(this IWebAssemblyHost host) { // Behave like async void, because we don't yet support async-main properly on WebAssembly. // However, don't actualy make this method async, because we rely on startup being synchronous // for things like attaching navigation event handlers. host.StartAsync().ContinueWith(task => { if (task.Exception != null) { Console.WriteLine(task.Exception); } }); }
public static IWebAssemblyHost InitializeApplicationServices(this IWebAssemblyHost webhost) { if (webhost == null) { throw new ArgumentNullException(nameof(webhost)); } var serviceProvider = webhost.Services; var applicationServiceManager = serviceProvider.GetService <ApplicationServiceManager>(); if (applicationServiceManager != null) { // TODO: https://github.com/AI4E/AI4E/issues/39 // There seems to be a dead-lock with the initialization of the messaging infrastructure if this is not off-loaded. // This does not seem to be true. ANY asnyc initialization that is not off-loaded locks up the process. This seems to be a live lock, // as there are many CPU cycles burnt without progress. Task.Run(() => applicationServiceManager.InitializeApplicationServicesAsync(serviceProvider, cancellation: default)); } return(webhost); }
/// <summary> /// Runs the application. /// </summary> /// <param name="host">The <see cref="IWebAssemblyHost"/> to run.</param> /// <remarks> /// Currently, Blazor applications running in the browser don't have a lifecycle - the application does not /// get a chance to gracefully shut down. For now, <see cref="Run(IWebAssemblyHost)"/> simply starts the host /// and allows execution to continue. /// </remarks> public static void Run(this IWebAssemblyHost host) { host.StartAsync().GetAwaiter().GetResult(); }