public ComputeThreadBasic(int id) { //_id = id; Id = id; _worker = new Thread(new ThreadStart(WorkingLoop)); _state = ComputeThreadState.Idle; _worker.Start(); }
private void WorkingLoop() { while (!_stop) { if (_work != null && _state == ComputeThreadState.Idle) { Thread.Sleep(1); _state = ComputeThreadState.Working; _work(); _work = null; _state = ComputeThreadState.Idle; } } }