File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( ) => {
You can’t perform that action at this time.
0 commit comments