Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void RunPoolThreads(int count, ThreadAction action)
- {
- // TODO: Run 'count' pool threads and execute 'action' in every one with appropriate range of data
- // TODO: Use 'ManualResetEvent' to synchronize operations
- int step = _data.Length / count;
- var x = 0;
- for (int i = 0; i < count ; i++)
- {
- var start = x;
- var stop = x + step;
- x += step;
- if (i == count - 1)
- {
- stop = _data.Length;
- }
- ThreadPool.QueueUserWorkItem( o => action(start, stop));
- manualResetEvent.WaitOne();
- manualResetEvent.Reset();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement