Skip to content

Commit be3b6eb

Browse files
committed
[edit] async
1 parent 06a1b09 commit be3b6eb

File tree

2 files changed

+10
-4
lines changed
  • src/templates/MyProjectWindowsServiceWithDatabase/MyProjectWindowsServiceWithDatabase.Service

2 files changed

+10
-4
lines changed

src/templates/MyProjectWindowsServiceWithDatabase/MyProjectWindowsServiceWithDatabase.Service/Program.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,10 @@
1717
// One-time launch of user code without the scheduler
1818

1919
using var scope = DIContainer.Current.BeginLifetimeScope();
20-
scope.Resolver.Resolve<Worker>().Run();
20+
21+
scope.Resolver.Resolve<Worker>()
22+
.Run()
23+
.ConfigureAwait(false)
24+
.GetAwaiter()
25+
.GetResult();
2126
}

src/templates/MyProjectWindowsServiceWithDatabase/MyProjectWindowsServiceWithDatabase.Service/Worker.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using MyProjectWindowsServiceWithDatabase.MyEntities;
1+
using System.Threading.Tasks;
2+
using MyProjectWindowsServiceWithDatabase.MyEntities;
23

34
namespace MyProjectWindowsServiceWithDatabase.Service;
45

@@ -8,9 +9,9 @@ internal class Worker
89

910
public Worker(IMyEntityServiceService service) => _service = service;
1011

11-
public void Run()
12+
public async Task Run()
1213
{
13-
var items = _service.GetAllAsync().Result;
14+
var items = await _service.GetAllAsync();
1415

1516
// TODO
1617
}

0 commit comments

Comments
 (0)