Exemplo n.º 1
0
        /// <summary>
        /// Method that refreshes the Cache by uploading all modified changes and then downloading the
        /// server changes.
        /// </summary>
        public void RefreshAsync()
        {
            if (this.IsBusy)
            {
                throw CacheControllerException.CreateCacheBusyException();
            }

            this.refreshStats = new CacheRefreshStatistics();

            this.StartAsyncWorkerManager();

            // Enqueue an async operation
            this._asyncWorkManager.AddWorkRequest(new AsyncWorkRequest(RefreshWorker, RefreshWorkerCompleted, null));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Instantiates a new AsyncWorkerManager object that will be used for the current sync session
 /// </summary>
 void StartAsyncWorkerManager()
 {
     if (this._asyncWorkManager == null)
     {
         lock (this._lockObject)
         {
             if (this._asyncWorkManager == null)
             {
                 this._asyncWorkManager          = new AsyncWorkerManager(OnRefreshCancelled);
                 this._controllerBehavior.Locked = true;
                 // Reset Cancelled flag
                 this.Cancelled = false;
             }
             else
             {
                 // This means two different threads raced and called RefreshAsync which wasnt caught by the IsBusy check
                 throw CacheControllerException.CreateCacheBusyException();
             }
         }
     }
 }