/// <summary>
        /// Adds hosting middleware functionality to the web host startup process which will delay the startup by the provided amount of time.
        /// </summary>
        /// <param name="hostBuilder">An instance of the program initialization abstraction that is to be modified.</param>
        /// <param name="delay">The amount of time that startup will be delayed.</param>
        /// <returns>The program initialization abstraction which has been augmented to apply a delayed start.</returns>
        /// <remarks>Multiple calls to this will apply consecutive delays.</remarks>
        public static IHostBuilder WithDelayedStart(this IHostBuilder hostBuilder, TimeSpan delay)
        {
            var options = new DelayedStartOptions()
            {
                Delay = delay
            };

            return(hostBuilder.UseHostingMiddleware(ctx => new DelayedStartHostingMiddleware(options)));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Intializes a new instance of the <see cref="DelayedStartHostingMiddleware"/> class, using the provided
 /// <paramref name="options"/> as its configuration.
 /// </summary>
 /// <param name="options">The configuration to use.</param>
 public DelayedStartHostingMiddleware(DelayedStartOptions options)
 {
     _options = options;
 }