public void Dispose() { if (this.disposed) { return; } this.disposed = true; DisposeOf(this.inputSubscriptions); TimeSpan pipelineDrainWaitTime = PollWaitForPipelineDrain(); pipelineHead.Complete(); // We want to give the completion logic some non-zero wait time for the pipeline blocks to dispose of their internal resources. TimeSpan completionWaitTime = TimeSpan.FromMilliseconds(Math.Max(100, this.pipelineConfiguration.PipelineCompletionTimeoutMsec - pipelineDrainWaitTime.TotalMilliseconds)); Task.WaitAll(this.pipelineCompletionTasks.ToArray(), completionWaitTime); this.cancellationTokenSource.Cancel(); DisposeOf(this.pipelineLinkDisposables); if (this.disposeDependencies) { DisposeOf(this.Inputs); DisposeOf(this.Sinks); HealthReporter.Dispose(); } }
public void Dispose() { lock (this.batcherTimerDisposalLock) { if (this.disposed) { return; } this.disposed = true; this.batcherTimer.Dispose(); } DisposeOf(this.inputSubscriptions); pipelineHead.Complete(); // The completion should propagate all the way to the outputs. When all outputs complete, the pipeline has been drained successfully. Task.WhenAny(Task.WhenAll(this.outputCompletionTasks.ToArray()), Task.Delay(this.pipelineConfiguration.PipelineCompletionTimeoutMsec)).GetAwaiter().GetResult(); this.cancellationTokenSource.Cancel(); if (this.disposeDependencies) { DisposeOf(this.Inputs); DisposeOf(this.Sinks); HealthReporter.Dispose(); } }
public void Dispose() { if (this.disposed) { return; } this.disposed = true; DisposeOf(this.inputSubscriptions); this.pipelineHead.Complete(); this.pipelineHead.Completion.Wait(TimeSpan.FromMilliseconds(this.pipelineConfiguration.PipelineCompletionTimeoutMsec)); this.cancellationTokenSource.Cancel(); DisposeOf(this.pipelineDisposables); if (this.disposeDependencies) { DisposeOf(this.Inputs); DisposeOf(this.Sinks); HealthReporter.Dispose(); } }