不要看任务管理器
你随便新建个winform工程,双击exe运行,线程数显示4
你随便新建个winform工程,双击exe运行,线程数显示4
解决方案 »
- 为什么C#用微软语音引擎朗读文件时整个窗口都处于瘫痪状态
- 小优化,不懂怎么处理!
- byte[] 复制数据到 结构体
- list.count() linq
- 请教一个combobox的触发事件
- 关于DNS根服务器的问题?
- DateTime.DayOfWeek的一个问题
- 水晶报表的宽度为只读怎么办?导致我无法使我的报表加更多的字段.还有我使用水晶报表前总是询问我是否注册?请问怎么注册?
- 打字软件中文件文字变色效果的实现
- 关于委托机制,事件处理算不算委托,还有,调用新建的一个线程算不算委托
- C# 操作多串口 问题
- 输出字符缓冲区太小,无法包含解码后的字符,编码 Unicode (UTF-8) 的操作回退
创建线程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);
}
}
}