Пример #1
0
        /// <summary>
        /// Called by the  to indicate that a
        /// synchronization session has started.
        /// </summary>
        public virtual async Task <(SyncContext, SyncConfiguration)> BeginSessionAsync(SyncContext context, MessageBeginSession message)
        {
            try
            {
                lock (this)
                {
                    if (this.syncInProgress)
                    {
                        throw new InProgressException("Synchronization already in progress");
                    }

                    this.syncInProgress = true;
                }

                // Progress & interceptor
                context.SyncStage = SyncStage.BeginSession;
                var sessionArgs = new SessionBeginArgs(context, null, null);
                this.ReportProgress(context, sessionArgs);
                await this.InterceptAsync(sessionArgs);

                return(context, message.Configuration);
            }
            catch (Exception ex)
            {
                throw new SyncException(ex, SyncStage.BeginSession);
            }
        }
Пример #2
0
        /// <summary>
        /// Called by the  to indicate that a
        /// synchronization session has started.
        /// </summary>
        public virtual async Task <SyncContext> BeginSessionAsync(SyncContext context,
                                                                  CancellationToken cancellationToken, IProgress <ProgressArgs> progress = null)
        {
            context.SyncStage = SyncStage.BeginSession;

            // Progress & interceptor
            var sessionArgs = new SessionBeginArgs(context, null, null);

            this.ReportProgress(context, progress, sessionArgs);
            await this.InterceptAsync(sessionArgs).ConfigureAwait(false);

            return(context);
        }
Пример #3
0
        /// <summary>
        /// Called by the  to indicate that a
        /// synchronization session has started.
        /// </summary>
        public async Task BeginSessionAsync(CancellationToken cancellationToken = default, IProgress <ProgressArgs> progress = null)
        {
            if (!this.StartTime.HasValue)
            {
                this.StartTime = DateTime.UtcNow;
            }

            // Get context or create a new one
            var ctx = this.GetContext();

            ctx.SyncStage = SyncStage.BeginSession;

            // Progress & interceptor
            var sessionArgs = new SessionBeginArgs(ctx, null, null);

            await this.InterceptAsync(sessionArgs, cancellationToken).ConfigureAwait(false);

            this.ReportProgress(ctx, progress, sessionArgs);
        }