Esempio n. 1
0
        /// <summary>
        /// Sync and wait, several times until a particular condition is satisfied.
        /// </summary>
        /// <returns>
        /// True if the condition got satisfied, false if the condition did not get satisfied within the time limit.
        /// </returns>
        /// <param name='synchronizedFolder'>
        /// Folder to synchronize.
        /// </param>
        /// <param name='checkStop'>
        /// If returns <c>true</c> wait returns true, otherwise a retry will be executed until reaching maxTries.
        /// </param>
        /// <param name='maxTries'>
        /// Number of retries, until false is returned, if checkStop could not be true.
        /// </param>
        /// <param name='pollInterval'>
        /// Sleep interval duration in miliseconds between synchronization calls.
        /// </param>
        public static bool SyncAndWaitUntilCondition(SynchronizedFolder synchronizedFolder, Func <bool> checkStop, int maxTries = 4, int pollInterval = 5000)
        {
            int i = 0;

            while (i < maxTries)
            {
                try
                {
                    synchronizedFolder.Sync();
                }
                catch (DotCMIS.Exceptions.CmisRuntimeException e)
                {
                    Console.WriteLine("{0} Exception caught and swallowed, retry.", e);
                    System.Threading.Thread.Sleep(pollInterval);
                    continue;
                }
                if (checkStop())
                {
                    return(true);
                }
                Console.WriteLine(String.Format("Retry Sync in {0}ms", pollInterval));
                System.Threading.Thread.Sleep(pollInterval);
                i++;
            }
            Console.WriteLine("Sync call was not successful");
            return(false);
        }
Esempio n. 2
0
 public void DoFirstSync()
 {
     Logger.Info(String.Format("CmisRepo | First sync", this.Name));
     if (cmis != null)
     {
         cmis.Sync();
     }
 }