202409091042 关于项目类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace Measure
{
    public class CThread
    {
        protected Thread _thread = null;
        
        protected bool _threadStatus = false;
        public int ThreadID;

        private static int _threadID = 0;
        /// <summary>
        /// 构造函数
        /// </summary>
        public CThread()
        {
            _threadID++;
            ThreadID = _threadID;
        }

        public bool m_Status
        {
            get { return _threadStatus; }
        }

        public virtual void Thread_Start()
        {
            _threadStatus = true;
        }

        public virtual void Thread_Stop()
        {
            _threadStatus = false;
        }

        /// <summary>
        /// 释放线程资源
        /// </summary>
        public virtual void Dispose()
        {
            if (_thread != null && _thread.ThreadState != ThreadState.Aborted)
            {
                _threadStatus = false;
                _thread.Abort();
                _thread = null;
            }
        }
    }
}

  

posted @ 2024-09-09 10:43  wenluderen  阅读(6)  评论(3编辑  收藏  举报