Skip to content

Commit 757ff7f

Browse files
committed
.
1 parent 029fed8 commit 757ff7f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

SMTP2Graph/Worker.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class Worker(ILogger<Worker> Logger) : BackgroundService
2323

2424
private readonly TcpListener MailListener = new(IPAddress.Any, 25);
2525

26-
protected override Task ExecuteAsync(CancellationToken stoppingToken)
26+
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
2727
{
2828
Logger.LogInformation("Initializing SMTP2Graph...");
2929

@@ -57,9 +57,9 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
5757
Environment.Exit(0);
5858
}
5959

60-
while (true)
60+
while (!stoppingToken.IsCancellationRequested)
6161
{
62-
var client = MailListener.AcceptTcpClient();
62+
var client = await MailListener.AcceptTcpClientAsync(stoppingToken);
6363
var port = ((IPEndPoint)client.Client.RemoteEndPoint!).Port;
6464
Logger.LogInformation(port, "Accepting connection, attempting to process...");
6565
_ = Task.Run(async () => {

0 commit comments

Comments
 (0)