protected override void OnDoWork(DoWorkEventArgs e)
{
while (!this.CancellationPending)
{
// Wait until a connection has been established
this.semReady.WaitOne();
Logging.Log("Display Handler", "Start working");
if (this.lcd)
{
foreach (KeyValuePair<iMonLcdIcons, bool> icon in this.icons)
{
this.imon.LCD.Icons.Set(icon.Key, icon.Value);
}
}
if (this.queue.Count > 0)
{
this.display(this.queue[0]);
if (this.queue.Count > 1)
{
this.position = 1;
}
}
while (!this.CancellationPending && (this.lcd || this.vfd))
{
this.semWork.WaitOne();
lock (this.queueLock)
{
if (this.position >= this.queue.Count)
{
this.position = 0;
}
this.display(this.queue[this.position]);
if (this.queue.Count > this.position + 1)
{
this.position += 1;
}
}
}
Logging.Log("Display Handler", "Stop working");
}
Logging.Log("Display Handler", "Cancelled");
this.imon.LCD.ScrollFinished -= lcdScrollFinished;
}