/// <summary>Blocks until the intial <see cref="Couchbase.Lite.Query"/> finishes.</summary> /// <remarks>If an error occurs while executing the <see cref="Couchbase.Lite.Query"/>, <see cref="LastError"/> /// will contain the exception. Can be cancelled if results are not returned after <see cref="DefaultQueryTimeout"/> (90 seconds).</remarks> public void WaitForRows() { Start(); while (true) { try { UpdateQueryTask.Wait(DefaultQueryTimeout, UpdateQueryTokenSource.Token); LastError = UpdateQueryTask.Exception; break; } catch (OperationCanceledException e) //TODO: Review { Log.D(Database.Tag, "Got operation cancel exception waiting for rows", e); continue; } catch (Exception e) { Log.E(Database.Tag, "Got interrupted exception waiting for rows", e); LastError = e; } } }
private void RunUpdateAfterQueryFinishes() { if (!runningState) { Log.D(Database.Tag, this + ": ReRunUpdateAfterQueryFinishes() fired, but running state == false. Ignoring."); return; // NOTE: Assuming that we don't want to lose rows we already retrieved. } if (UpdateQueryTask != null) { try { UpdateQueryTask.Wait(DefaultQueryTimeout, UpdateQueryTokenSource.Token); if (!UpdateQueryTokenSource.IsCancellationRequested) { Update(); } } catch (Exception e) { Log.E(Database.Tag, "Got an exception waiting for Update Query Task to finish", e); } } }