private void button1_Click(object sender, EventArgs e) { if (_isPlaying) { return; } for (int i = 0; i < NodeMgr._nodeList.Count; i++) { DataPlay playThread = new DataPlay(this, i); playThread._playMode = getPlayMode(); _threadList.Add(playThread); playThread.toStart(); } _isPlaying = true; }
private void stopPlay(object sender, EventArgs e) { if (_isPlaying == false) { return; } for (int i = 0; i < _threadList.Count; i++) { DataPlay playThread = _threadList[i]; if (playThread != null) { playThread.toStop(); } } _threadList.Clear(); _isPlaying = false; Thread.Sleep(200);//暂停一下让写线程结束 }