void OnDestroy()
        {
            foreach (var thread in registeredThreads)
            {
                thread.Dispose();
            }

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

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