/
IHost.cs
35 lines (31 loc) · 1.53 KB
/
IHost.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.Extensions.Hosting
{
/// <summary>
/// A program abstraction.
/// </summary>
public interface IHost : IDisposable
{
/// <summary>
/// Gets the services configured for the program (for example, using <see cref="M:HostBuilder.ConfigureServices(Action<HostBuilderContext,IServiceCollection>)" />).
/// </summary>
IServiceProvider Services { get; }
/// <summary>
/// Starts the <see cref="IHostedService" /> objects configured for the program.
/// The application will run until interrupted or until <see cref="M:IHostApplicationLifetime.StopApplication()" /> is called.
/// </summary>
/// <param name="cancellationToken">Used to abort program start.</param>
/// <returns>A <see cref="Task"/> that will be completed when the <see cref="IHost"/> starts.</returns>
Task StartAsync(CancellationToken cancellationToken = default);
/// <summary>
/// Attempts to gracefully stop the program.
/// </summary>
/// <param name="cancellationToken">Used to indicate when stop should no longer be graceful.</param>
/// <returns>A <see cref="Task"/> that will be completed when the <see cref="IHost"/> stops.</returns>
Task StopAsync(CancellationToken cancellationToken = default);
}
}