You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewException("Pooler task has to be type 'delegate', 'Pooler.TaskDelegate' (void accepting first param to be 'Pooler.Base') or 'Func<Pooler.Base, object>'.");
/// <param name="priority">Background thread priority for task executing.</param>
94
94
/// <param name="async">If task is using any other threads to work or async code, set this to true and call pool.AsyncTaskDone() call after your task is done manualy.</param>
95
95
/// <returns>Current threads pool instance.</returns>
Copy file name to clipboardExpand all lines: README.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ Pooler.Parallel pool = Pooler.Parallel.CreateNew(10);
33
33
for (inti=0; i<500; i++) {
34
34
pool.Add(
35
35
// any delegate or void to process
36
-
(Pooler.Basepool) => {
36
+
(Pooler.Parallelpool) => {
37
37
doubledummyResult=Math.Pow(Math.PI, Math.PI);
38
38
},
39
39
// optional - do not run task instantly after adding, run them a few lines later together
@@ -55,13 +55,13 @@ pool.Add(delegate {
55
55
doubledummyResult=Math.Pow(Math.PI, Math.PI);
56
56
});
57
57
// ... or to add task as any void function accepting first param as Pooler type:
58
-
pool.Add((Pooler.Basep) => {
58
+
pool.Add((Pooler.Parallelp) => {
59
59
doubledummyResult=Math.Pow(Math.PI, Math.PI);
60
60
});
61
61
62
-
// ... or to add task as Func<Pooler.Base, object> function:
62
+
// ... or to add task as Func<Pooler.Parallel, object> function:
63
63
// accepting first param as Pooler type and returning any result:
64
-
pool.Add((Pooler.Basep) => {
64
+
pool.Add((Pooler.Parallelp) => {
65
65
returnMath.Pow(Math.PI, Math.PI);
66
66
});
67
67
// ... then you can pick up returned result in pool.TaskDone event:
@@ -141,7 +141,7 @@ int pausemiliseconds = pool.GetPauseMiliseconds();
141
141
142
142
2. Use `pool.Pause();` method sometimes in your hard task:
143
143
```cs
144
-
pool.Add((Pooler.Basep) => {
144
+
pool.Add((Pooler.Parallelp) => {
145
145
doublesomeHardCode1=Math.Pow(Math.PI, Math.PI);
146
146
p.Pause();
147
147
doublesomeHardCode2=Math.Pow(Math.PI, Math.PI);
@@ -169,7 +169,7 @@ pool = Pooler.Repeater.CreateNew(10, 500, 100);
169
169
pool=newPooler.Repeater(10, 500, 100);
170
170
```
171
171
- First (optional) param is max. threads in background to executing one specific task. 10 by default.
172
-
- Second (optional) param is how many times will be specific task executed. Null means infinite, then you need to use pool.StopAll(); somewhere in the future manualy.
172
+
- Second (optional) param is how many times will be specific task executed. Null means infinite (zero - 0 - doesn't means infinite), then you need to use pool.StopAll(); or pool.StopCurrent(); somewhere in the task body in the future future manualy.
173
173
- Third (optional) param is pause miliseconds to slow down CPU load or other resources by `pool.Pause();` calls inside your task, 0 by default.
174
174
175
175
#### Repeater instance and single specific task setup:
@@ -180,13 +180,13 @@ pool.Set(delegate {
180
180
doubledummyResult=Math.Pow(Math.PI, Math.PI);
181
181
});
182
182
// ... or set task as any void function accepting first param as Pooler type:
183
-
pool.Set((Pooler.Basep) => {
183
+
pool.Set((Pooler.Repeaterp) => {
184
184
doubledummyResult=Math.Pow(Math.PI, Math.PI);
185
185
});
186
186
187
-
// ... or set task as Func<Pooler.Base, object> function:
187
+
// ... or set task as Func<Pooler.Repeater, object> function:
188
188
// accepting first param as Pooler type and returning any result:
189
-
pool.Set((Pooler.Basep) => {
189
+
pool.Set((Pooler.Repeaterp) => {
190
190
returnMath.Pow(Math.PI, Math.PI);
191
191
});
192
192
// ... then you can pick up returned result as before in pool.TaskDone event:
@@ -223,7 +223,7 @@ To use any other threads or async code in your pool tasks, you need to tell pool
Copy file name to clipboardExpand all lines: Repeater.cs
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ public class Repeater: Base {
38
38
/// Create and return new threads pool instance, nowhere regstered, just created.
39
39
/// </summary>
40
40
/// <param name="maxRunningTasks">Max threads running in parallel to execute given tasks.</param>
41
-
/// <param name="tasksCount">Tasks count to process repeatedly, zero means infinite.</param>
41
+
/// <param name="tasksCount">Tasks count to process repeatedly, null means infinite.</param>
42
42
/// <param name="pauseMiliseconds">Miliseconds for pooler.Pause(); call inside any task to slow down CPU or any other computer resources for each running thread in threads pool.</param>
@@ -47,7 +47,7 @@ public Repeater (int maxRunningTasks = 10, int? tasksCount = null, int pauseMili
47
47
/// Get single instance from Parallel.instance place created only once.
48
48
/// </summary>
49
49
/// <param name="maxRunningTasks">Max threads running in parallel to execute given tasks.</param>
50
-
/// <param name="tasksCount">Tasks count to process repeatedly, zero means infinite.</param>
50
+
/// <param name="tasksCount">Tasks count to process repeatedly, null means infinite.</param>
51
51
/// <param name="pauseMiliseconds">Miliseconds for pooler.Pause(); call inside any task to slow down CPU or any other computer resources for each running thread in threads pool.</param>
52
52
/// <returns>static instance created only once.</returns>
/// Create and return new threads pool instance, nowhere regstered, just created.
61
61
/// </summary>
62
62
/// <param name="maxRunningTasks">Max threads running in parallel to execute given tasks.</param>
63
-
/// <param name="tasksCount">Tasks count to process repeatedly, zero means infinite.</param>
63
+
/// <param name="tasksCount">Tasks count to process repeatedly, null means infinite.</param>
64
64
/// <param name="pauseMiliseconds">Miliseconds for pooler.Pause(); call inside any task to slow down CPU or any other computer resources for each running thread in threads pool.</param>
65
65
/// <returns>New threads pool instance to use.</returns>
@@ -124,7 +124,7 @@ public Repeater Set (Func<Repeater, object> task, bool runInstantly = true, Thre
124
124
/// <param name="priority">Background thread priority for task executing.</param>
125
125
/// <param name="async">If task is using any other threads to work or async code, set this to true and call pool.AsyncTaskDone() call after your task is done manualy.</param>
126
126
/// <returns>Current threads pool instance.</returns>
0 commit comments