public override async Task ExecuteAsync(CancellationToken cancellationToken) { log.Trace($"{nameof(ExecuteAsync)}"); this.cancellationToken = cancellationToken; messenger.AddMulticastSubscription <AllPointsBulletin>((m) => APBHandler(m as AllPointsBulletin)); messenger.AddMulticastSubscription <PlayerCommand>(async(m) => await PlayerCommandHandler(m as PlayerCommand)); while (!this.cancellationToken.IsCancellationRequested) { try { await Task.Delay(10000); } catch (Exception xe) { log.Error(xe); } } if (cancellationToken.IsCancellationRequested) { log.Debug($"CancellationRequested"); } return; }
protected /*public*/ override async Task ExecuteAsync(CancellationToken cancellationToken) { messenger.AddMulticastSubscription <DeviceStatus>(async(m) => { await OnDeviceStatus(m); }); this.taskList.Add(Task.Run(() => { this.sim = new ServerInformationMulticast(environment, messengerOptions, musicServerOptions, messenger, cancellationToken, lf); sim.Start().ContinueWith(sim.OnException, TaskContinuationOptions.OnlyOnFaulted); this.keepAlive = new KeepAgentsAlive(musicServerOptions, cancellationToken, lf); this.keepAlive.Start(this.GetPlayerUrls(), async(url) => { await PlayerDead(url); }).ContinueWith(keepAlive.OnException, TaskContinuationOptions.OnlyOnFaulted); }, cancellationToken)); await Task.WhenAll(taskList); }