C# 多线程
/*********************************************************************** C# 多線程* 說明:* 在上位機的編碼中多線程是很常用的方式,網絡編程中更是常用。** 2016-12-9 深圳 南山平山村 曾劍鋒*********************************************************************/一、參考文檔:Unable to inherit from a Thread Class in C# ?http://stackoverflow.com/questions/8123461/unable-to-inherit-from-a-thread-class-in-c-sharp
二、解決方法:abstract class BaseThread{private Thread _thread;protected BaseThread() { _thread = new Thread(new ThreadStart(this.RunThread)); }// Thread methods / propertiespublic void Start() { _thread.Start(); }public void Join() { _thread.Join(); }public bool IsAlive { get { return _thread.IsAlive; } }// Override in base classpublic abstract void RunThread();}public MyThread : BaseThread{public override void RunThread() {// Do some stuff
}}
?
轉載于:https://www.cnblogs.com/zengjfgit/p/6149690.html
總結
- 上一篇: Linux系统面试常问问题,最常见的Li
- 下一篇: pythonxml模块高级用法_Pyth