public void Start(int count, Action onDone) { State = ThreadManagerState.Started; SortQueue(); _onDone = onDone; _pool = Enumerable.Range(0, count) .Select(x => new Thread(ThreadProcess) { IsBackground = true }) .ToArray(); for (var i = 0; i < _pool.Length; i++) { if (_pool[i] != null) { _pool[i].Start(); } } }
private void Stop() { _onDone?.Invoke(); _onDone = null; State = ThreadManagerState.Stopped; }