private void SleepWhileSuspended()
{
if (syncWorker.CancellationPending)
{
//Sync was cancelled...
throw new OperationCanceledException("Sync was cancelled by user.");
}
if ( ! repo.Enabled)
{
while ( ! repo.Enabled)
{
enabled = true;
Logger.DebugFormat("Sync of {0} is suspend, next retry in {1}ms", repoInfo.Name, SYNC_SUSPEND_SLEEP_INTERVAL);
System.Threading.Thread.Sleep(SYNC_SUSPEND_SLEEP_INTERVAL);
if (syncWorker.CancellationPending)
{
//Sync was cancelled...
repo.Enable();
throw new OperationCanceledException("Suspended sync was cancelled by user.");
}
}
enabled = false;
}
}
}