File tree 3 files changed +10
-17
lines changed
3 files changed +10
-17
lines changed Original file line number Diff line number Diff line change 1
1
<Project Sdk =" Microsoft.NET.Sdk.Web" >
2
2
3
3
<PropertyGroup >
4
- <TargetFramework >net6 .0-windows</TargetFramework >
4
+ <TargetFramework >net8 .0-windows</TargetFramework >
5
5
<Nullable >enable</Nullable >
6
6
<ImplicitUsings >enable</ImplicitUsings >
7
7
</PropertyGroup >
8
8
9
9
<ItemGroup >
10
- <PackageReference Include =" Microsoft.Extensions.Hosting.WindowsServices" Version =" 6 .0.0 " />
11
- <PackageReference Include =" Swashbuckle.AspNetCore" Version =" 6.3 .0" />
10
+ <PackageReference Include =" Microsoft.Extensions.Hosting.WindowsServices" Version =" 8 .0.1 " />
11
+ <PackageReference Include =" Swashbuckle.AspNetCore" Version =" 6.9 .0" />
12
12
</ItemGroup >
13
13
14
14
</Project >
Original file line number Diff line number Diff line change 1
- <Project Sdk =" Microsoft.NET.Sdk.Worker" >
1
+ <Project Sdk =" Microsoft.NET.Sdk.Worker" >
2
2
3
3
<PropertyGroup >
4
- <TargetFramework >net7 .0</TargetFramework >
4
+ <TargetFramework >net8 .0</TargetFramework >
5
5
<Nullable >enable</Nullable >
6
6
<ImplicitUsings >enable</ImplicitUsings >
7
7
<UserSecretsId >dotnet-SimpleWorkerService-39D11380-59B5-4EE1-B441-64FB46CAE1C9</UserSecretsId >
8
8
</PropertyGroup >
9
9
10
10
<ItemGroup >
11
- <PackageReference Include =" Microsoft.Extensions.Hosting" Version =" 7 .0.0-preview.1.22076.8 " />
12
- <PackageReference Include =" Microsoft.Extensions.Hosting.WindowsServices" Version =" 6 .0.0 " />
11
+ <PackageReference Include =" Microsoft.Extensions.Hosting" Version =" 8 .0.1 " />
12
+ <PackageReference Include =" Microsoft.Extensions.Hosting.WindowsServices" Version =" 8 .0.1 " />
13
13
</ItemGroup >
14
14
</Project >
Original file line number Diff line number Diff line change 1
1
namespace SimpleWorkerService ;
2
2
3
- public class Worker : BackgroundService
3
+ public class Worker ( ILogger < Worker > logger ) : BackgroundService
4
4
{
5
- private readonly ILogger < Worker > _logger ;
6
-
7
- public Worker ( ILogger < Worker > logger , IHostEnvironment environment )
8
- {
9
- _logger = logger ;
10
- }
11
-
12
5
protected override async Task ExecuteAsync ( CancellationToken stoppingToken )
13
6
{
14
7
string [ ] args = Environment . GetCommandLineArgs ( ) ;
15
- _logger . LogInformation ( "command line args: {args}" , string . Join ( " " , args ) ) ;
8
+ logger . LogInformation ( "command line args: {args}" , string . Join ( " " , args ) ) ;
16
9
17
10
while ( ! stoppingToken . IsCancellationRequested )
18
11
{
19
- _logger . LogInformation ( "Worker running at: {time}" , DateTimeOffset . Now ) ;
12
+ logger . LogInformation ( "Worker running at: {time}" , DateTimeOffset . Now ) ;
20
13
await Task . Delay ( 10000 , stoppingToken ) ;
21
14
}
22
15
}
You can’t perform that action at this time.
0 commit comments