c# ThreadPool 应用实例
2014-11-21 00:51
225 查看
namespace ThreadPoolTestCase { class Program { static void Main(string[] args) { for (int i = 0; i < 10000; i++) { int state = i; AssignWork(state); Console.WriteLine(i); } Console.ReadKey(); } public static void AssignWork(object s) { ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), (object)s); Console.WriteLine(s); //wait.Reset(); } private static void DoWork(object o) {//may be smtp works here; Console.WriteLine("abcdef"); for (int i = 0; i < 100000; i++) { Console.WriteLine("abcdef"); Thread.Sleep(1000); } // } } }
相关文章推荐
- c#的ThreadPool使用笔记(四)--实例:端口扫描程序
- c#的ThreadPool使用笔记(一)
- C# multithread,threadpool,ParameterizedThreadStart,传递参数给线程以及回调
- C# WinForm多线程(二)---- ThreadPool 与 Timer
- C#中事务的应用实例(转)
- C#中动态数组(ArrayList )应用实例子
- 【C#.NET】C#皮肤与主题应用实例
- ThreadPool 线程池[c#]
- C#中WebChart的应用实例
- ThreadPool 线程池[c#]收藏(2009-05-26 15:49:47)
- 应用Executors来建立Thread pool
- 利用c#制作托盘程序,并禁止多个应用实例运行
- 应用Executors来建立Thread pool
- [原] C# 3.0的委托(delegate)及Lambda表达式应用实例
- c#中的委托和事件的简单实例_c#应用
- c#的ThreadPool使用笔记(二)
- 应用Executors来建立Thread pool
- 应用Executors来建立Thread pool
- C#线程系列讲座(2):Thread类的应用
- 【原创】 ASP.NET C#反射简单实例应用