Пример #1
0
        public void CreateThread(string threadname, int seconds, string pythonscripts)
        {
            if (_threadDictionary.Keys.Contains(threadname))
            {
                throw new Exception("线程[" + threadname + "]已经存在!禁止重复创建。");
            }

            ParameterManager pm = new ParameterManager();

            pm.Add("threadname", threadname);
            pm.Add("pythonscripts", pythonscripts);
            pm.Add("seconds", seconds);

            //System.Threading.Thread thread = new Thread(new ParameterizedThreadStart(EnableButton));
            //thread.Start(null);

            System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(ThreadRunning));
            thread.IsBackground = true;
            thread.Name         = threadname;
            thread.Start(pm);//线程开始。。。

            //
            _threadDictionary.Add(threadname, thread);
            _threadStopFlagDictionary.Add(threadname, true);
        }