public void RenderAndPollIndeterminate(Func<bool> heartbeat, TimeSpan pollingInterval)
{
Render();
indeterminateHighlightIndex = 0;
bool cancelled = false;
try
{
var bgTask = Task.Factory.StartNew(() =>
{
while (cancelled == false)
{
Update();
indeterminateHighlightIndex++;
if (indeterminateHighlightIndex > Width - 4)
{
indeterminateHighlightIndex = 0;
}
Thread.Sleep(50);
}
});
while (heartbeat())
{
Thread.Sleep(pollingInterval);
}
}
finally
{
indeterminateHighlightIndex = -1;
Update();
cancelled = true;
}
}