private string GetResourceResult(string verb, string uri, string key, string queryPath, string resourceType = "", string resourceValue = "", string body = "", bool jsonQuery = false) { Task <string> resourceTask = TinyDocDB_HttpRequestHelper.PerformResourceRequest(verb, uri, key, queryPath, resourceType, resourceValue, body, jsonQuery); try { resourceTask.Wait(); } catch (ObjectDisposedException ex) { throw new TinyDocDB_Exception("Resource task had already completed or been destroyed", ex); } catch (AggregateException ex) { throw new TinyDocDB_Exception("Errors occured updating the resource", ex); } return(resourceTask.Result); }
private void ResourceUpdate_Elapsed(object sender, ElapsedEventArgs e) { if (resourceUpdate != null) { resourceUpdate.Stop(); } Task <string> getResourceTask = TinyDocDB_HttpRequestHelper.PerformResourceRequest("get", rURI, rKey, rPath, rTypeName, rPath); try { getResourceTask.Wait(); } catch (ObjectDisposedException ex) { throw new TinyDocDB_Exception("Resource task had already completed or been destroyed", ex); } catch (AggregateException ex) { throw new TinyDocDB_Exception("Errors occured updating the resource", ex); } if (getResourceTask.Result != cachedResponse) { cachedResponse = getResourceTask.Result; TinyDocDB_UpdateEventArgs updateEventArgs = new TinyDocDB_UpdateEventArgs(); updateEventArgs.updatedResourceOutput = cachedResponse; updateEventArgs.UpdatedTime = DateTime.Now; OnResourceUpdate(updateEventArgs); } if (resourceUpdate != null) { try { resourceUpdate.Start(); } catch (ArgumentOutOfRangeException ex) { throw new TinyDocDB_Exception("Invalid polling interval specified (Resource Update Timer)", ex); } } }