2 using System
.Threading
;
8 public static void test_callback (object state
) {
10 int completionPortThreads
;
11 ThreadPool
.GetAvailableThreads (out workerThreads
, out completionPortThreads
);
12 Console
.WriteLine("test_casllback:" + state
+ "ATH: " + workerThreads
);
15 Interlocked
.Increment (ref csum
);
18 public static int Main () {
20 int completionPortThreads
;
23 ThreadPool
.GetMaxThreads (out workerThreads
, out completionPortThreads
);
24 Console
.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads
, completionPortThreads
);
26 ThreadPool
.GetAvailableThreads (out workerThreads
, out completionPortThreads
);
27 Console
.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads
, completionPortThreads
);
29 for (int i
= 0; i
< runs
; i
++) {
30 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST1 " + i
);
31 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST2 " + i
);
32 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST3 " + i
);
33 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST4 " + i
);
34 ThreadPool
.QueueUserWorkItem (new WaitCallback (test_callback
), "TEST5 " + i
);
37 ThreadPool
.GetAvailableThreads (out workerThreads
, out completionPortThreads
);
38 if (workerThreads
== 0)
40 } while (workerThreads
== 0);
43 ThreadPool
.GetAvailableThreads (out workerThreads
, out completionPortThreads
);
44 Console
.WriteLine ("workerThreads: {0} completionPortThreads: {1}", workerThreads
, completionPortThreads
);
47 while (csum
< (runs
* 5)) {
52 Console
.WriteLine ("CSUM: " + csum
);
54 if (csum
!= (runs
* 5))