public static void HandleViewCompilation(this ViewCompilationConfiguration compilationConfiguration, DotvvmConfiguration config, IStartupTracer startupTracer) { if (compilationConfiguration.Mode == ViewCompilationMode.Lazy) { return; } var getCompilationTask = compilationConfiguration.Precompile(config, startupTracer); if (compilationConfiguration.Mode == ViewCompilationMode.DuringApplicationStart) { getCompilationTask.Wait(); } }
public static Task Precompile(this ViewCompilationConfiguration compilationConfiguration, DotvvmConfiguration config, IStartupTracer startupTracer) { return(Task.Run(async() => { var compilationService = config.ServiceProvider.GetService <IDotvvmViewCompilationService>(); if (compilationConfiguration.BackgroundCompilationDelay != null) { await Task.Delay(compilationConfiguration.BackgroundCompilationDelay.Value); } startupTracer.TraceEvent(StartupTracingConstants.ViewCompilationStarted); await compilationService.CompileAll(compilationConfiguration.CompileInParallel, false); startupTracer.TraceEvent(StartupTracingConstants.ViewCompilationFinished); })); }