Thanks.
I don't think I will use AbstractUpdateIndexTrigger because as I can tell, the only thing I can figure out is when a batch is processed, not when the index is done. To wait for index not to be stale I have written this:
public static Task WaitForIndexNotStaleAsync(this DocumentDatabase db, string indexName, DateTime? cutOff, Guid cuttOfEtag, TimeSpan timeout)
{
return Task.Factory.StartNew(() =>
{
TimeSpan delayIncrement = TimeSpan.FromMilliseconds(50);
TimeSpan currentDelay = TimeSpan.FromMilliseconds(100);
DateTime timeLimit = DateTime.UtcNow.Add(timeout);
while (db.IsIndexStale(indexName, cutOff, cuttOfEtag))
{
if (DateTime.UtcNow > timeLimit)
throw new TimeoutException("Timeout exceeded waiting for index not to be stale");
TaskExtensions.Delay(currentDelay).Wait();
currentDelay = currentDelay.Add(delayIncrement);
}
});
}
I hate to do polling. But the other way is too complex.
Do you thing is this a good enough approach?
Thanks.
On Thursday, August 2, 2012 6:24:11 AM UTC+2, Oren Eini wrote:
inline