Exemplo n.º 1
0
            public Task <bool> GetSynchronizationTaskAsync(int requiredHostDocumentVersion, CancellationToken cancellationToken)
            {
                // Cancel any out-of-date existing synchronizing contexts.

                for (var i = _synchronizingContexts.Count - 1; i >= 0; i--)
                {
                    var context = _synchronizingContexts[i];
                    if (context.RequiredHostDocumentVersion < requiredHostDocumentVersion)
                    {
                        // All of the existing synchronizations that are older than this version are no longer valid.
                        context.SetSynchronized(result: false);
                        _synchronizingContexts.RemoveAt(i);
                    }
                }

                var synchronizingContext = new DocumentSynchronizingContext(requiredHostDocumentVersion, _synchronizingTimeout, cancellationToken);

                _synchronizingContexts.Add(synchronizingContext);
                return(synchronizingContext.OnSynchronizedAsync);
            }
 public void UpdateSynchronizingContext(int requiredHostDocumentVersion, CancellationToken cancellationToken)
 {
     // Cancel our existing synchronizing context.
     SynchronizingContext?.SetSynchronized(result: false);
     SynchronizingContext = new DocumentSynchronizingContext(requiredHostDocumentVersion, _synchronizingTimeout, cancellationToken);
 }