public FetchCloudDataWorker(DatastoreService dataStore, string projectId, KindName kindName, ResultsLimit skip, long editDate, bool fetchOldData) { query = getQueryRequest1(skip, editDate, fetchOldData, kindName); res = dataStore.Projects.RunQuery(query , projectId); _dataStore = dataStore; _projectId = projectId; _kindName = kindName; _skip = skip; _editDate = editDate; _fetchOldData = fetchOldData; }
private static async Task <RunQueryResponse> execQuery(ProjectsResource.RunQueryRequest res, int numAttempts = 4) { RunQueryResponse response = null; var fetched = false; for (int i = 0; i < numAttempts; i++) { try { response = await res.ExecuteAsync(); fetched = true; } catch (Google.GoogleApiException gex) { //todo: mark this record as bad to prevent it blocking for life //cloudDb.InsertOrReplace(new OutEntityUnsynced().load(outEntity)); //cloudDb.Delete<OutEntity>(saveable.Id.Value); //break; } catch (System.Net.WebException wex) { //perhaps lost connection //we alllow it to spin for now } catch (Exception ex) { //ex.Message //"A task was canceled." //unknown exception } if (fetched) { break; } else { //lets add a 2 second delay in case it failed the first time //lets log that we had to wait, try x await Task.Delay(TimeSpan.FromMilliseconds(2000)); } } return(response); }