Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
 protected virtual void OnResourceUpdate(TinyDocDB_UpdateEventArgs e)
 {
     ResourceUpdate?.Invoke(this, e);
 }