/// <summary> /// This method is called when the <see cref="T:Microsoft.Extensions.Hosting.IHostedService" /> /// starts. The implementation should return a task that represents the lifetime of the long /// running operation(s) being performed. /// </summary> /// /// <param name="stoppingToken"> Triggered when /// <see cref="M:Microsoft.Extensions.Hosting.IHostedService.StopAsync(System.Threading.CancellationToken)" /> /// is called. </param> /// /// <returns> /// A <see cref="T:System.Threading.Tasks.Task" /> that represents the long running operations. /// </returns> protected override async Task ExecuteAsync(CancellationToken stoppingToken) { CancellationToken = stoppingToken; Logger.Log(LogLevel.Trace, "NotificationsService:ExecuteAsync Service Starting"); ListenerAdapter.Start(Configuration.NotificationServerPort); Logger.Log(LogLevel.Information, "NotificationsService:ExecuteAsync Service Started"); ListenerAdapter.BeginAcceptConnection(ClientConnectedAsyncCallback); Logger.Log(LogLevel.Trace, "NotificationsService:ExecuteAsync Waiting for new client to connect"); while (!stoppingToken.IsCancellationRequested) { await Task.Delay(Configuration.NotificationServerKeepAlivePeriod, stoppingToken); } Logger.Log(LogLevel.Trace, "NotificationsService:ExecuteAsync Service Stopping"); }
public void Setup() { _adapter = new ListenerAdapter <Profile>(); }