2 using System
.Threading
;
4 public class ThreadPoolTest
9 public static void test_callback (object state
) {
10 Console
.WriteLine("test_callback:" + state
);
12 Interlocked
.Increment (ref csum
);
15 public static int Main () {
17 int completionPortThreads
;
19 ThreadPool
.GetMaxThreads (out workerThreads
, out completionPortThreads
);
20 Console
.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads
, completionPortThreads
);
22 ThreadPool
.GetAvailableThreads (out workerThreads
, out completionPortThreads
);
23 Console
.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads
, completionPortThreads
);
25 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST1");
26 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST2");
27 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST3");
28 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST4");
29 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST5");
30 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
));
36 Console
.WriteLine ("CSUM: " + csum
);