-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.fs
33 lines (28 loc) · 1.38 KB
/
Program.fs
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
open BackgroundTasksSample.ConsumeScopedServiceHostedService
open BackgroundTasksSample.ScopedProcessingService
open BackgroundTasksSample.Services
open BackgroundTasksSample.Services.BackgroundTaskQueue
open BackgroundTasksSample.Services.MonitorLoop
open BackgroundTasksSample.Services.QueuedHostedService
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Hosting
open BackgroundTasksSample.TimedHostedService
[<EntryPoint>]
let main argv =
async {
let hostBuilder = Host.CreateDefaultBuilder()
hostBuilder.ConfigureServices(fun hostContext services ->
services.AddSingleton<MonitorLoop>() |> ignore
services.AddHostedService<QueuedHostedService>() |> ignore
services.AddSingleton<IBackgroundTaskQueue, BackgroundTaskQueue>() |> ignore
services.AddHostedService<TimedHostedService>() |> ignore
services.AddHostedService<ConsumeScopedServiceHostedService>() |> ignore
services.AddScoped<IScopedProcessingService, ScopedProcessingService>() |> ignore)
|> ignore
let host = hostBuilder.Build()
let! _ = host.StartAsync() |> Async.AwaitTask
let monitorLoop = host.Services.GetRequiredService<MonitorLoop>()
monitorLoop.StartMonitorLoop() |> ignore
return! host.WaitForShutdownAsync() |> Async.AwaitTask
} |> Async.RunSynchronously
0