diff MonoPlay/Program.cs @ 120:f1b897999260 v2

improved asyncpool usability working on batch operations on asyncqueue
author cin
date Mon, 12 Jan 2015 05:19:52 +0300
parents 2573b562e328
children 62d2f1e98c4e
line wrap: on
line diff
--- a/MonoPlay/Program.cs	Sun Jan 11 19:13:02 2015 +0300
+++ b/MonoPlay/Program.cs	Mon Jan 12 05:19:52 2015 +0300
@@ -19,30 +19,30 @@
 
             var t1 = Environment.TickCount;
 
-            new [] {
-                AsyncPool.InvokeNewThread(() => {
+            AsyncPool.ThreadRun(
+                () => {
                     for (var i = 0; i < count; i++)
                         q1.Enqueue(i);
-                }),
-                AsyncPool.InvokeNewThread(() => {
+                },
+                () => {
                     for (var i = 0; i < count; i++)
                         q1.Enqueue(i);
-                }),
-                AsyncPool.InvokeNewThread(() => {
+                },
+                () => {
                     int temp = 0;
                     int i = 0;
                     while (i < count)
                         if (q1.TryDequeue(out temp))
                             i++;
-                }),
-                AsyncPool.InvokeNewThread(() => {
+                },
+                () => {
                     int temp = 0;
                     int i = 0;
                     while (i < count)
                         if (q1.TryDequeue(out temp))
                             i++;
-                })
-            }
+                }
+            )
                 .Combine()
                 .Join();
 
@@ -65,18 +65,18 @@
             t1 = Environment.TickCount;
 
          
-            new [] {
-                AsyncPool.InvokeNewThread(() => {
+            AsyncPool.ThreadRun(
+                () => {
                     for (var i = 0; i < count; i++)
                         lock (q2)
                             q2.Enqueue(i);
-                }),
-                AsyncPool.InvokeNewThread(() => {
+                },
+                () => {
                     for (var i = 0; i < count; i++)
                         lock (q2)
                             q2.Enqueue(i);
-                }),
-                AsyncPool.InvokeNewThread(() => {
+                },
+                () => {
                     for (int i = 0; i < count ;)
                         lock (q2) {
                             if (q2.Count == 0)
@@ -85,8 +85,8 @@
                             i++;
                         }
 
-                }),
-                AsyncPool.InvokeNewThread(() => {
+                },
+                () => {
                     for (int i = 0; i < count ;)
                         lock (q2) {
                             if (q2.Count == 0)
@@ -95,8 +95,8 @@
                             i++;
                         }
 
-                })
-            }
+                }
+            )
                 .Combine()
                 .Join();