/// <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); }
/// <summary> /// Constructor. /// </summary> public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener) : base(repoInfo, activityListener) { this.synchronizedFolder = new SynchronizedFolder(repoInfo, this, activityListener); this.Watcher.ChangeEvent += OnFileActivity; this.Watcher.EnableEvent = true; Logger.Info(synchronizedFolder); }
public CmisRepo(RepoInfo repoInfo, ActivityListener activityListener) : base(repoInfo) { cmis = new SynchronizedFolder(repoInfo, activityListener, this); Logger.Info("CmisRepo | " + cmis); }
/// <summary> /// Constructor. /// </summary> public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener) : base(repoInfo) { this.synchronizedFolder = new SynchronizedFolder(repoInfo, activityListener, this); Logger.Info(synchronizedFolder); }
/// <summary> /// Constructor. /// </summary> public CmisRepo(RepoInfo repoInfo, IActivityListener activityListener, bool enableWatcher) : base(repoInfo, activityListener, enableWatcher) { this.synchronizedFolder = new SynchronizedFolder(repoInfo, this, activityListener); Logger.Info(synchronizedFolder); }
/// <summary> /// Update repository settings. /// </summary> public override void UpdateSettings(string password, int pollInterval) { base.UpdateSettings(password, pollInterval); this.synchronizedFolder = new SynchronizedFolder(RepoInfo, this); Logger.Info(synchronizedFolder); }