Esempio n. 1
0
        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();
                }
            }
        }
Esempio n. 2
0
 private void Stop()
 {
     _onDone?.Invoke();
     _onDone = null;
     State   = ThreadManagerState.Stopped;
 }