public void Execute(CancellationToken cancel)
{
try
{
this.log.Info("Starting up listeners, etc");
this.log.Info("Running");
if (this.autoStartBackgroundTrack)
PlayNextBackground();
var watch = Stopwatch.StartNew();
int reportCounter = 0;
while (!cancel.IsCancellationRequested)
{
if (this.piFace != null)
this.piFace.PollInputPins();
if (this.fmodSystem != null)
this.fmodSystem.Update();
this.disposeList.ForEach(x => x.Dispose());
this.disposeList.Clear();
reportCounter++;
if (reportCounter % 5 == 0)
{
if (ReportChannelPosition(this.currentTrkChannel, this.currentTrack, AudioTypes.Track, ref this.lastPosTrk))
watch.Restart();
}
if (reportCounter % 10 == 0)
{
if (ReportChannelPosition(this.currentBgChannel, this.currentBgTrackName, AudioTypes.Background, ref this.lastPosBg))
watch.Restart();
}
if (reportCounter % 10 == 0 && watch.ElapsedMilliseconds > 5000)
{
// Send ping
this.log.Trace("Send ping");
SendMessage(new Ping());
watch.Restart();
}
Thread.Sleep(50);
}
this.log.Info("Shutting down");
}
finally
{
Console.CursorVisible = true;
}
}
}