sdk/dotnet/src/Microsoft.Datasync.Client/Offline/SyncContext.cs
/// <summary>
/// Enqueues an operation and updates the offline store.
/// </summary>
/// <param name="operation">The table operation to enqueue.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> to observe.</param>
/// <returns>A task that completes when the operation is enqueued on the operations queue.</returns>
Enqueues an operation and updates the offline store.
Enqueues an operation and updates the offline store .
private async Task EnqueueOperationAsync(TableOperation operation, JObject instance, CancellationToken cancellationToken)
        {
            using (await queueLock.WriterLockAsync(cancellationToken).ConfigureAwait(false))
            {
                TableOperation existingOperation = await OperationsQueue.GetOperationByItemIdAsync(operation.TableName, operation.ItemId, cancellationToken).ConfigureAwait(false);
                existingOperation?.ValidateOperationCanCollapse(operation);
                try
                {
                    await operation.ExecuteOperationOnOfflineStoreAsync(OfflineStore, instance, cancellationToken).ConfigureAwait(false);
                }
                catch (Exception ex) when (ex is not OfflineStoreException)
                {
                    throw new OfflineStoreException("Failed to perform operation on local store.", ex);
                }
                if (existingOperation != null)
                {
                    existingOperation.CollapseOperation(operation);
                    if (existingOperation.IsCancelled)
                    {
                        await OperationsQueue.DeleteOperationByIdAsync(existingOperation.Id, existingOperation.Version, cancellationToken).ConfigureAwait(false);
                    }
                    else if (existingOperation.IsUpdated)
                    {
                        await OperationsQueue.UpdateOperationAsync(existingOperation, cancellationToken).ConfigureAwait(false);
                    }
                }
                if (!operation.IsCancelled)
                {
                    await OperationsQueue.EnqueueOperationAsync(operation, cancellationToken).ConfigureAwait(false);
                }
            }
        }
private async Task EnqueueOperationAsync ( TableOperation operation , JObject instance , CancellationToken cancellationToken ) { using ( await queueLock . WriterLockAsync ( cancellationToken ) . ConfigureAwait ( false ) ) { TableOperation existingOperation = await OperationsQueue . GetOperationByItemIdAsync ( operation . TableName , operation . ItemId , cancellationToken ) . ConfigureAwait ( false ) ; existingOperation ? . ValidateOperationCanCollapse ( operation ) ; try { await operation . ExecuteOperationOnOfflineStoreAsync ( OfflineStore , instance , cancellationToken ) . ConfigureAwait ( false ) ; } catch ( Exception ex ) when ( ex is not OfflineStoreException ) { throw new OfflineStoreException ( " " , ex ) ; } if ( existingOperation != null ) { existingOperation . CollapseOperation ( operation ) ; if ( existingOperation . IsCancelled ) { await OperationsQueue . DeleteOperationByIdAsync ( existingOperation . Id , existingOperation . Version , cancellationToken ) . ConfigureAwait ( false ) ; } else if ( existingOperation . IsUpdated ) { await OperationsQueue . UpdateOperationAsync ( existingOperation , cancellationToken ) . ConfigureAwait ( false ) ; } } if ( ! operation . IsCancelled ) { await OperationsQueue . EnqueueOperationAsync ( operation , cancellationToken ) . ConfigureAwait ( false ) ; } } }
Enqueues an operation and updates the offline store.
Enqueues an operation and updates the offline store .
// See if there is an existing operation.  If there is, then validate that it can be collapsed. // Execute the operation on the local store. // If there is an existing operation, then collapse the operation with the previous one.
A task that completes when the operation is enqueued on the operations queue.
A task that completes when the operation is enqueued on the operations queue .
operation
TableOperation
The table operation to enqueue.
The table operation to enqueue .
instance
JObject
cancellationToken
CancellationToken
A  to observe.
A to observe .