ThreadPool.QueueUserWorkItem性能测试与提高
2016-07-01 15:29
645 查看
int minWorker, minIOC; // Get the current settings. ThreadPool.GetMinThreads(out minWorker, out minIOC); this.textBox1.AppendText(string.Format("min worker number {0}\r\n", minWorker)); ThreadPool.SetMinThreads(10, minIOC); ThreadPool.GetMinThreads(out minWorker, out minIOC); this.textBox1.AppendText(string.Format("set min worker number to {0}\r\n", minWorker)); for (int index = 0; index < 9; index++) { ThreadPool.QueueUserWorkItem((indexParam) => { int threadID = Thread.CurrentThread.ManagedThreadId; Thread.Sleep(1000); BeginInvoke((Action)delegate { this.textBox1.AppendText("Completed " + indexParam.ToString() + " using thread " + threadID.ToString() + " (" + DateTime.Now.Second.ToString() + "." + DateTime.Now.Millisecond.ToString("000") + ")\r\n"); }); }, index); Thread.Sleep(20); }
相关文章推荐
- easyui 选中指定行
- uuid/uuid.h: 没有这个文件或目录
- H-ui小技巧
- 用UIButton做出cell的点击效果《一》
- iOS UI篇12- 本地通知
- iOS 获取图片某一点的颜色对象UIColor
- 关于UITableViewStyle (转载)
- BZOJ2632 [neerc2011]Gcd guessing game
- suite0001关于ABCD类地址
- 蓝牙BlueTooth技术学习理解
- 蓝牙BlueTooth技术学习理解
- vue.js——初体验
- XML i:nil="true"
- windows环境下mosquitto环境搭建与mqtt测试
- DocumentBuilderFactory.setNamespaceAware(true)慎用
- 加快UE4 Setup.bat执行速度
- Androids属性动画PropertyValuesHolder的使用
- UE4 射线拾取&三维画线
- UE4 射线拾取&三维画线
- iOS与Android用户界面(UI)设计规范