不要看任务管理器
你随便新建个winform工程,双击exe运行,线程数显示4

解决方案 »

  1.   

    代码逻辑是这样的:
    创建线程ReadPrintReturn,然后把线程放进list里, 在线程函数PrintReturn里,执行完毕后会把model.IsPrinted 设置为true.
    Thread readThread = new Thread(PrintReturn);
                                        PrinterThread model = new PrinterThread();
                                        model.TID = name + TaskCode + PrintCode;
                                        model.RunThread = readThread;
                                        model.IsPrinted = false;
                                        threadList.Add(model);循环list的任务:日志记录 item.IsPrinted是true的,也就是线程是执行完了的。
     foreach (PrinterThread item in threadList)
                    {
                        if (null != item.RunThread )
                        {
                           WriteLog(item.TID, item.IsPrinted.ToString());
                            if (item.IsPrinted)
                            {
                                item.RunThread.Abort();
                                threadList.Remove(item);
                            }
                  
                        }
             
                    }