System.Collections.Concurrent.BlockingCollection.Dispose()

Here are the examples of the csharp api class System.Collections.Concurrent.BlockingCollection.Dispose() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

77 Examples 7

1. Example

Project: memcache-driver
Source File: NodeQueueMock.cs
public void Dispose()
        {
            _queue.Dispose();
        }

2. Example

Project: EnyimMemcached2
Source File: NodeQueue.cs
public void Dispose()
		{
			queue.Dispose();
		}

3. Example

Project: EventFlow
Source File: RabbitMqConsumer.cs
public void Dispose()
        {
            _eventingBasicConsumer.Received -= OnReceived;
            _model.Dispose();
            _connection.Dispose();
            _receivedMessages.Dispose();
        }

4. Example

Project: Toxy
Source File: ImageCache.cs
public virtual void Dispose()
        {
            if (imageQueue != null)
            {
                imageQueue.Dispose();
            }
        }

5. Example

Project: kino
Source File: AsyncQueue.cs
public void Dispose()
            => asyncResponses.Dispose();

6. Example

Project: Easy.Common
Source File: ProducerConsumerQueue.cs
public void Dispose()
        {
            _queue?.Dispose();
        }

7. Example

Project: PSParallel
Source File: PowershellPool.cs
public void Dispose()
		{
			Streams.Dispose();
			_availablePoolMembers.Dispose();			
		}

8. Example

Project: rudymq
Source File: InputChannelListener.cs
protected override void OnClose(TimeSpan timeout)
        {
            this.channelQueue.Dispose();
        }

9. Example

Project: CodeJam
Source File: ParallelQueue.cs
private void Dispose(bool disposing)
		{
			if (disposing)
				_queue.Dispose();
		}

10. Example

Project: inVtero.net
Source File: FileLoader.cs
protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (HDB != null)
                        HDB.Dispose();


                    if (ReadyQueue != null)
                        ReadyQueue.Dispose();

                    HDB = null;
                    ReadyQueue = null;
                }
                disposedValue = true;
            }
        }

11. Example

Project: ShareX
Source File: ImageCache.cs
public virtual void Dispose()
        {
            if (imageQueue != null)
            {
                imageQueue.Dispose();
            }
        }

12. Example

Project: EventBus
Source File: OrderedEventBus.cs
protected virtual void Dispose(bool disposing)
        {
            if (!_isDisposed)
            {
                if (disposing)
                {
                    _eventQueue.Dispose();
                }
                _isDisposed = true;
            }
        }

13. Example

Project: AsyncEx.Context
Source File: AsyncContext.TaskQueue.cs
public void Dispose()
            {
                _queue.Dispose();
            }

14. Example

Project: ShareX
Source File: ImageCache.cs
public virtual void Dispose()
        {
            if (imageQueue != null)
            {
                imageQueue.Dispose();
            }
        }

15. Example

Project: Gwupe
Source File: BlockingStream.cs
protected override void Dispose(bool disposing)
        {
            base.Dispose(disposing);
            if (disposing)
            {
                _blocks.Dispose();
            }
        }

16. Example

Project: NugetCracker
Source File: ConsoleDispatcher.cs
protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_keyBuffer != null)
                {
                    _keyBuffer.Dispose();
                }

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

17. Example

Project: revenj
Source File: PostgresConnectionPool.cs
public void Dispose()
		{
			try
			{
				foreach (var con in Connections)
				{
					try { con.Close(); }
					catch (Exception ex) { TraceSource.TraceEvent(TraceEventType.Error, 5013, "{0}", ex); }
				}
				Connections.Dispose();
				NpgsqlConnection.ClearAllPools();
			}
			catch (Exception e) { TraceSource.TraceEvent(TraceEventType.Error, 5014, "{0}", e); }
		}

18. Example

Project: revenj
Source File: ScopePool.cs
public void Dispose()
		{
			try
			{
				foreach (var s in Scopes)
				{
					try
					{
						Queries.EndQuery(s.Query, false);
						s.Factory.Dispose();
					}
					catch (Exception ex)
					{
						TraceSource.TraceEvent(TraceEventType.Error, 5303, "{0}", ex);
					}
				}
				Scopes.Dispose();
			}
			catch (Exception ex2)
			{
				TraceSource.TraceEvent(TraceEventType.Error, 5304, "{0}", ex2);
			}
		}

19. Example

Project: Lean
Source File: BusyBlockingCollection.cs
public void Dispose()
        {
            _collection.Dispose();
            _processingCompletedEvent.Dispose();
        }

20. Example

Project: Lean
Source File: EnqueueableEnumerator.cs
public void Dispose()
        {
            lock (_lock)
            {
                if (_disposed) return;
                Stop();
                if (_blockingCollection != null) _blockingCollection.Dispose();
                _disposed = true;
            }
        }

21. Example

Project: QDMS
Source File: ContinuousFuturesBroker.cs
public void Dispose()
        {
            if (_reconnectTimer != null)
                _reconnectTimer.Dispose();
            if (_client != null)
            {
                _client.Dispose();
                _client = null;
            }
            if (_frontContractRequests != null)
                _frontContractRequests.Dispose();
        }

22. Example

Project: NuGet
Source File: ConsoleDispatcher.cs
protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_keyBuffer != null)
                {
                    _keyBuffer.Dispose();
                }

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

23. Example

Project: CANAPE.Core
Source File: LockedQueue.cs
void IDisposable.Dispose()
        {
            _queue.Dispose();
            GC.SuppressFinalize(this);
        }

24. Example

Project: oleviewdotnet
Source File: LockedQueue.cs
void IDisposable.Dispose()
        {
            _queue.Dispose();
            GC.SuppressFinalize(this);
        }

25. Example

Project: CloudFS
Source File: ProducerConsumerStream.cs
protected override void Dispose(bool disposing)
        {
            if (disposing)
                blocks.Dispose();

            base.Dispose(disposing);
        }

26. Example

Project: NuTracer
Source File: TracerManager.cs
public void Dispose()
        {
            cancellation.Cancel();
            traceQueue.Dispose();
        }

27. Example

Project: NosDB
Source File: RecoveryPersistenceQueue.cs
public void Dispose()
        {
            try
            {
                if (documentCollection != null)
                {
                    documentCollection.Dispose();
                }

                if (_cancelToken != null)
                    _cancelToken.Dispose();
            }
            catch (Exception exp)
            {
                if (LoggerManager.Instance.RecoveryLogger != null && LoggerManager.Instance.RecoveryLogger.IsErrorEnabled)
                    LoggerManager.Instance.RecoveryLogger.Error("RecoveryPersistenceQueue.Dispose()", exp.ToString());
            }
        }

28. Example

Project: NLog.Targets.Syslog
Source File: AsyncLogger.cs
public void Dispose()
        {
            cts.Cancel();
            cts.Dispose();
            queue.Dispose();
            buffer.Dispose();
            messageTransmitter.Dispose();
        }

29. Example

Project: waf
Source File: UnitTestSynchronizationContext.cs
private void Dispose(bool isDisposing)
        {
            if (isDisposed) { return; }
            isDisposed = true;

            if (isDisposing)
            {
                FinishMessageQueue();
                messageQueue.Dispose();
                SetSynchronizationContext(previousContext);
            }
        }

30. Example

Project: QDMS
Source File: RealTimeDataBroker.cs
public void Dispose()
        {
            if (_cfBroker != null)
            {
                _cfBroker.Dispose();
                _cfBroker = null;
            }
            if (_connectionTimer != null)
            {
                _connectionTimer.Dispose();
                _connectionTimer = null;
            }
            foreach(var dataSource in DataSources.Where(ds => ds.Value is IDisposable))
            {
                ((IDisposable)dataSource.Value).Dispose();
            }
            /*if (DataSources.ContainsKey("Interactive Brokers"))
            {
                ((IB)DataSources["Interactive Brokers"]).Dispose();
            }*/

            if (_arrivedBars != null)
                _arrivedBars.Dispose();
        }

31. Example

Project: FabricTableService
Source File: PersistentTablePool.cs
public void Dispose()
        {
            this.pool.CompleteAdding();
            this.pool.Dispose();

            PersistentTable<TKey, TValue> table;
            while (this.allInstances.TryTake(out table))
            {
                table.Dispose();
            }

            var instance = this.Instance;
            if (instance == null)
            {
                return;
            }

            instance.TermGrbit = TermGrbit.Complete;
            instance.Term();
            instance.Dispose();
            this.Instance = null;
        }

32. Example

Project: Rubberduck
Source File: StaTaskScheduler.cs
public void Dispose()
        {
            if (_tasks != null)
            {
                _tasks.CompleteAdding();
                foreach (var thread in _threads)
                {
                    thread.Join();
                }

                _tasks.Dispose();
                _tasks = null;
            }
        }

33. Example

Project: microsoft-authentication-library-for-dotnet
Source File: StaTaskScheduler.cs
public void Dispose()
        {
            if (_tasks != null)
            {
                // Indicate that no new tasks will be coming in
                _tasks.CompleteAdding();

                // Wait for all threads to finish processing tasks
                foreach (var thread in _threads) thread.Join();

                // Cleanup
                _tasks.Dispose();
                _tasks = null;
            }
        }

34. Example

Project: azure-activedirectory-library-for-dotnet
Source File: StaTaskScheduler.cs
public void Dispose()
        {
            if (_tasks != null)
            {
                // Indicate that no new tasks will be coming in
                _tasks.CompleteAdding();

                // Wait for all threads to finish processing tasks
                foreach (var thread in _threads) thread.Join();

                // Cleanup
                _tasks.Dispose();
                _tasks = null;
            }
        }

35. Example

Project: msgpack-rpc-cli
Source File: InProcServerTransportManager.cs
protected sealed override void Dispose( bool disposing )
		{
			if ( !this._cancellationTokenSource.IsCancellationRequested )
			{
				this._cancellationTokenSource.Cancel();
			}

			this._cancellationTokenSource.Dispose();

			foreach ( var entry in this._arrivedQueueTable )
			{
				var queue = entry.Value;
				if ( queue != null )
				{
					queue.Dispose();
				}
			}

			foreach ( var entry in this._receivingQueueTable )
			{
				var queue = entry.Value;
				if ( queue != null )
				{
					queue.Dispose();
				}
			}

			base.Dispose( disposing );
		}

36. Example

Project: carbonator
Source File: CarbonatorInstance.cs
public static void StopCollection()
        {
            if (!_started)
                return;
            _started = false;

            _metricCollectorTimer.Dispose();
            _metricReporterTimer.Dispose();

            if (_tcpClient != null && _tcpClient.Connected)
                _tcpClient.Close();

            foreach (var watcher in _watchers)
            {
                watcher.Dispose();
            }
            _watchers.Clear();

            _metricsList.Dispose();
        }

37. Example

Project: hazelcast-csharp-client
Source File: StripedTaskScheduler.cs
public void Dispose()
        {
            if (_tasks != null)
            {
                // Indicate that no new tasks will be coming in
                foreach (var task in _tasks)
                {
                    task.Value.CompleteAdding();
                }

                // Wait for all threads to finish processing tasks
                foreach (var thread in _threads) thread.Join();

                // Cleanup
                foreach (var task in _tasks)
                {
                    task.Value.Dispose();
                }
                _tasks = null;
                _threads.Clear();
            }
        }

38. Example

Project: kino
Source File: MessageHub.cs
private void SendClientRequests(CancellationToken token)
        {
            try
            {
   /n ..... /n //View Source file for more details /n }

39. Example

Project: kino
Source File: ScaleOutListener.cs
public void Stop()
        {
            cancellationTokenSource?.Cancel();
            listening?.Wait();
            receiptConfirmation?.Wait();
            cancellationTokenSource?.Dispose();
            receiptConfirmationQueue?.Dispose();
        }

40. Example

Project: StarryEyes
Source File: StreamWinder.cs
private static void StartParserWorker([NotNull] BlockingCollection<string> collection,
            [NotNull] Action<string> parser, CancellationToken token)
        {
            if (collection == null) throw new ArgumentNullException(nameof(collection));
            if (parser == null) throw new ArgumentNullException(nameof(parser));
            const TaskCreationOptions option = TaskCreationOptions.DenyChildAttach |
                                               TaskCreationOptions.LongRunning;
            Task.Factory.StartNew(() =>
            {
                try
                {
                    foreach (var item in collection.GetConsumingEnumerable(token))
                    {
                        parser(item);
                    }
                }
                finally
                {
                    collection.Dispose();
                }
            }, token, option, TaskScheduler.Default);
        }

41. Example

Project: echo-process
Source File: PausableBlockingQueue.cs
public void Dispose()
        {
            Cancel();
            tokenSource?.Dispose();
            pauseWait?.Dispose();
            items?.Dispose();
        }

42. Example

Project: echo-process
Source File: PausableBlockingQueue.cs
public void Dispose()
        {
            Cancel();
            tokenSource?.Dispose();
            pauseWait?.Dispose();
            items?.Dispose();
        }

43. Example

Project: journeyofcode
Source File: SingleThreadTaskScheduler.cs
private void ThreadStart()
        {
            try
            {
                var token = this._cancellationToken.Token;

                this._initAction();

                foreach (var task in this._tasks.GetConsumingEnumerable(token))
                    this.TryExecuteTask(task);
            }
            finally
            {
                this._tasks.Dispose();
            }
        }

44. Example

Project: ServiceBusExplorer
Source File: PartitionListenerControl.cs
protected override void Dispose(bool disposing)
        {
            try
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }

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

                //if (cancellationTokenSource != null)
                //{
                //    cancellationTokenSource.Dispose();
                //}

                if (receiverEventDataInspector != null)
                {
                    var disposable = receiverEventDataInspector as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }

                for (var i = 0; i < Controls.Count; i++)
                {
                    Controls[i].Dispose();
                }

                base.Dispose(disposing);
            }
            // ReSharper disable once EmptyGeneralCatchClause
            catch
            {
            }
        }

45. Example

Project: ServiceBusExplorer
Source File: ContainerForm.cs
private void StartLog()
        {
            if (logCollection != null)
            {
                logCollection.Dispose();
            }
            logCollection = new BlockingCollection<string>();
            cancellationTokenSource = new CancellationTokenSource();
            logTask = Task.Factory.StartNew(AsyncWriteToLog).ContinueWith(t =>
            {
                if (t.IsFaulted && t.Exception != null)
                {
                    WriteToLog(t.Exception.Message);
                }
            });
        }

46. Example

Project: ServiceBusExplorer
Source File: MainForm.cs
private void StartLog()
        {
            if (logCollection != null)
            {
                logCollection.Dispose();
            }
            logCollection = new BlockingCollection<string>();
            cancellationTokenSource = new CancellationTokenSource();
            logTask = Task.Factory.StartNew(AsyncWriteToLog).ContinueWith(t =>
            {
                if (t.IsFaulted && t.Exception != null)
                {
                    WriteToLog(t.Exception.Message);
                }
            });
        }

47. Example

Project: ACDDokanNet
Source File: UploadService.cs
protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    Stop();
                    cancellation.Dispose();
                    uploadLimitSemaphore.Dispose();
                    leftUploads.Dispose();
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.
                disposedValue = true;
            }
        }

48. Example

Project: RampUp
Source File: RoundRobinThreadAffinedTaskScheduler.cs
public void Dispose()
        {
            if (_tasks != null)
            {
                _tasks.CompleteAdding();

                _threads.ForEach(t => t.Join());

                _tasks.Dispose();
                _tasks = null;
            }
        }

49. Example

Project: inVtero.net
Source File: CloudLoader.cs
public void QueryHashes(HashRecord[] hashArr)
        {
            ParallelOptions po = new Paralle/n ..... /n //View Source file for more details /n }

50. Example

Project: Harvester
Source File: MessageProcessor.cs
public void Dispose()
        {
            lock (syncLock)
            {
                if (cancellationTokenSource.IsCancellationRequested)
                    return;

                cancellationTokenSource.Cancel();
                processor.Join();

                cancellationTokenSource.Dispose();
                messageQueue.Dispose();
            }
        }