4 using System.Collections.Generic;
5 using System.Threading.Tasks;
7 namespace SiliconStudio.
Paradox.Threading
22 public static void Dispatch<T>(
IList<T> items,
int threadCount,
int threshold, Action<int, T> action)
26 for (
int i = 0; i < items.Count; i++)
28 var entity = items[i];
34 var
count = items.Count / threadCount;
36 var tasks =
new Task[threadCount];
39 for (
int i = 0; i < threadCount; i++)
41 if ((i + 1) == threadCount)
43 count += items.Count - count * threadCount;
46 var localIndex = fromIndex;
47 var localCount =
count;
51 for (
int j = 0; j < localCount; j++)
53 var entity = items[j + localIndex];
54 action(j + localIndex, entity);
_In_ size_t _In_ DXGI_FORMAT _In_ size_t _In_ float threshold
System.Threading.Tasks.Task Task
Helper methods to dispatch action-items from a list to several threads.