/// <inheritdoc />
        public void Dispose()
        {
            Trace.WriteLine("ENTER: Disposing {0} ...".FormatInvariant(this.debugName));

            switch (this.disposeState)
            {
            case DisposeState.Disposing:
            case DisposeState.Disposed:
                Trace.WriteLine("EXIT: {0} state is {1}.".FormatInvariant(this.debugName, this.disposeState));
                return;
            }

            this.disposeState = DisposeState.Disposing;

            Helpers.TryToExecute(() => this.MonitorPerformance = false);

            foreach (var task in this.activeTasksByTaskId)
            {
                TaskProcessExecutor.TryToKillProcess(task.Key, task.Value);
            }

            this.activeTasksByTaskId.Clear();
            this.activeTasksByProcess.Clear();
            this.canceledTasksById.Clear();

            GC.SuppressFinalize(this);

            this.disposeState = DisposeState.Disposed;

            Trace.WriteLine("EXIT: {0} disposed.".FormatInvariant(this.debugName));
        }
        /// <inheritdoc />
        public void CancelTask(Guid taskId)
        {
            Trace.WriteLine("ENTER: Cancelling task '{0}' ...".FormatInvariant(taskId));

            switch (this.disposeState)
            {
            case DisposeState.Disposing:
            case DisposeState.Disposed:
                throw new ObjectDisposedException(this.debugName);
            }

            Process process;

            if (!this.activeTasksByTaskId.TryGetValue(taskId, out process))
            {
                Trace.WriteLine("EXIT: Task '{0}' is not executed by me.".FormatInvariant(taskId));

                return;
            }

            this.canceledTasksById.Add(taskId);

            Thread.Sleep(this.cancelTimeout);

            TaskProcessExecutor.TryToKillProcess(taskId, process);

            Trace.WriteLine("EXIT: Task '{0}' canceled.".FormatInvariant(taskId));
        }