/// <summary> /// Called by the to indicate that a /// synchronization session has started. /// </summary> public virtual Task <(SyncContext, SyncConfiguration)> BeginSessionAsync(SyncContext context, MessageBeginSession message) { try { lock (this) { if (this.syncInProgress) { throw new InProgressException("Synchronization already in progress"); } this.syncInProgress = true; } // Set stage context.SyncStage = SyncStage.BeginSession; // Event progress var progressEventArgs = new BeginSessionEventArgs(this.ProviderTypeName, context.SyncStage, null, null); this.TryRaiseProgressEvent(progressEventArgs, this.BeginSession); return(Task.FromResult((context, message.Configuration))); } catch (Exception ex) { throw new SyncException(ex, SyncStage.BeginSession, this.ProviderTypeName); } }
/// <summary> /// Called by the to indicate that a /// synchronization session has started. /// </summary> public virtual Task <SyncContext> BeginSessionAsync(SyncContext context) { try { Debug.WriteLine($"BeginSession() called on Provider {this.ProviderTypeName}"); lock (this) { if (this.syncInProgress) { throw SyncException.CreateInProgressException(context.SyncStage); } this.syncInProgress = true; } // Set stage context.SyncStage = SyncStage.BeginSession; // Event progress var progressEventArgs = new BeginSessionEventArgs(this.ProviderTypeName, context.SyncStage); this.TryRaiseProgressEvent(progressEventArgs, this.BeginSession); } catch (Exception ex) { if (ex is SyncException) { throw; } else { throw SyncException.CreateUnknowException(context.SyncStage, ex); } } return(Task.FromResult(context)); }