sdk/dotnet/src/Microsoft.Datasync.Client/Offline/SyncContext.cs
/// <summary>
/// Pushes items in the operations queue for the list of tables to the remote service.
/// </summary>
/// <param name="tableNames">The list of table names to push.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
/// <returns>A task that completes when the push operation has finished.</returns>
/// <exception cref="PushFailedException">if the push operation failed.</exception>
Pushes items in the operations queue for the list of tables to the remote service.
Pushes items in the operations queue for the list of tables to the remote service .
public async Task PushItemsAsync(string[] tableNames, CancellationToken cancellationToken = default)
        {
            EnsureContextIsInitialized();
            var batch = new OperationBatch(this);
            cancellationToken.Register(() => batch.Abort(PushStatus.CancelledByToken));
            try
            {
                TableOperation operation = await OperationsQueue.PeekAsync(0, tableNames, cancellationToken).ConfigureAwait(false);
                while (operation != null)
                {
                    _ = await ExecutePushOperationAsync(operation, batch, true, cancellationToken).ConfigureAwait(false);
                    if (batch.AbortReason.HasValue)
                    {
                        break;
                    }
                    operation = await OperationsQueue.PeekAsync(operation.Sequence, tableNames, cancellationToken).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                batch.OtherErrors.Add(ex);
            }
            List<TableOperationError> errors = new();
            PushStatus batchStatus = batch.AbortReason ?? PushStatus.Complete;
            try
            {
                errors.AddRange(await batch.LoadErrorsAsync(cancellationToken).ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                batch.OtherErrors.Add(new OfflineStoreException("Failed to read errors from the local store.", ex));
            }
            if (batchStatus != PushStatus.Complete || batch.HasErrors(errors))
            {
                List<TableOperationError> unhandledErrors = errors.Where(error => !error.Handled).ToList();
                Exception innerException = batch.OtherErrors.Count > 0 ? new AggregateException(batch.OtherErrors) : null;
                throw new PushFailedException(new PushCompletionResult(unhandledErrors, batchStatus), innerException);
            }
        }
public async Task PushItemsAsync ( string [ ] tableNames , CancellationToken cancellationToken = default ) { EnsureContextIsInitialized ( ) ; var batch = new OperationBatch ( this ) ; cancellationToken . Register ( ( ) => batch . Abort ( PushStatus . CancelledByToken ) ) ; try { TableOperation operation = await OperationsQueue . PeekAsync ( 0 , tableNames , cancellationToken ) . ConfigureAwait ( false ) ; while ( operation != null ) { _ = await ExecutePushOperationAsync ( operation , batch , true , cancellationToken ) . ConfigureAwait ( false ) ; if ( batch . AbortReason . HasValue ) { break ; } operation = await OperationsQueue . PeekAsync ( operation . Sequence , tableNames , cancellationToken ) . ConfigureAwait ( false ) ; } } catch ( Exception ex ) { batch . OtherErrors . Add ( ex ) ; } List < TableOperationError > errors = new ( ) ; PushStatus batchStatus = batch . AbortReason ?? PushStatus . Complete ; try { errors . AddRange ( await batch . LoadErrorsAsync ( cancellationToken ) . ConfigureAwait ( false ) ) ; } catch ( Exception ex ) { batch . OtherErrors . Add ( new OfflineStoreException ( " " , ex ) ) ; } if ( batchStatus != PushStatus . Complete || batch . HasErrors ( errors ) ) { List < TableOperationError > unhandledErrors = errors . Where ( error => ! error . Handled ) . ToList ( ) ; Exception innerException = batch . OtherErrors . Count > 0 ? new AggregateException ( batch . OtherErrors ) : null ; throw new PushFailedException ( new PushCompletionResult ( unhandledErrors , batchStatus ) , innerException ) ; } }
Pushes items in the operations queue for the list of tables to the remote service.
Pushes items in the operations queue for the list of tables to the remote service .
// Main Push Operations Loop // If there were errors, then create a push failed exception. // If the push did not complete successfully, then throw a PushFailedException.
A task that completes when the push operation has finished.
A task that completes when the push operation has finished .
if the push operation failed.
if the push operation failed .
tableNames
string[]
The list of table names to push.
The list of table names to push .
cancellationToken
CancellationToken
A  to observe.
A to observe .