Ejemplo n.º 1
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public override void Dispose()
        {
#if DEBUG
            GC.SuppressFinalize(this);
#endif


            foreach (var observeChangesAndEvictItemsFromCacheForDatabase in observeChangesAndEvictItemsFromCacheForDatabases)
            {
                observeChangesAndEvictItemsFromCacheForDatabase.Value.Dispose();
            }

            var tasks = new List <Task>();
            foreach (var databaseChange in databaseChanges)
            {
                var remoteDatabaseChanges = databaseChange.Value as RemoteDatabaseChanges;
                if (remoteDatabaseChanges != null)
                {
                    tasks.Add(remoteDatabaseChanges.DisposeAsync());
                }
                else
                {
                    using (databaseChange.Value as IDisposable) { }
                }
            }

            foreach (var replicationInformer in replicationInformers)
            {
                replicationInformer.Value.Dispose();
            }

            // try to wait until all the async disposables are completed
            Task.WaitAll(tasks.ToArray(), TimeSpan.FromSeconds(3));

            if (Subscriptions != null)
            {
                Subscriptions.Dispose();
            }

            if (AsyncSubscriptions != null)
            {
                AsyncSubscriptions.Dispose();
            }

            // if this is still going, we continue with disposal, it is for grace only, anyway

            if (jsonRequestFactory != null)
            {
                jsonRequestFactory.Dispose();
            }

            WasDisposed = true;
            var afterDispose = AfterDispose;
            if (afterDispose != null)
            {
                afterDispose(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public virtual void Dispose()
        {
            if (jsonRequestFactory != null)
            {
                jsonRequestFactory.Dispose();
            }
            WasDisposed = true;
            var afterDispose = AfterDispose;

            if (afterDispose != null)
            {
                afterDispose(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
#if DEBUG
            GC.SuppressFinalize(this);
#endif

            var tasks = new List <Task>();
            foreach (var fileSystemChange in fileSystemChanges)
            {
                var remoteFileSystemChanges = fileSystemChange.Value as FilesChangesClient;
                if (remoteFileSystemChanges != null)
                {
                    tasks.Add(remoteFileSystemChanges.DisposeAsync());
                }
                else
                {
                    using (fileSystemChange.Value as IDisposable) { }
                }
            }

            foreach (var fileSystemCommand in fileSystemCommands)
            {
                var remoteFileSystemCommand = fileSystemCommand.Value as IDisposable;
                if (remoteFileSystemCommand != null)
                {
                    remoteFileSystemCommand.Dispose();
                }
            }

            foreach (var replicationInformer in replicationInformers)
            {
                replicationInformer.Value.Dispose();
            }

            // try to wait until all the async disposables are completed
            Task.WaitAll(tasks.ToArray(), TimeSpan.FromSeconds(5));

            // if this is still going, we continue with disposal, it is for grace only, anyway
            if (jsonRequestFactory != null)
            {
                jsonRequestFactory.Dispose();
            }

            WasDisposed = true;
            AfterDispose(this, EventArgs.Empty);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public override void Dispose()
        {
#if DEBUG
            GC.SuppressFinalize(this);
#endif

            if (jsonRequestFactory != null)
            {
                jsonRequestFactory.Dispose();
            }
#if !SILVERLIGHT
            foreach (var replicationInformer in replicationInformers)
            {
                replicationInformer.Value.Dispose();
            }
#endif
            WasDisposed = true;
            var afterDispose = AfterDispose;
            if (afterDispose != null)
            {
                afterDispose(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public virtual void Dispose()
 {
     jsonRequestFactory.Dispose();
     Stored = null;
 }