Not sure of exact needs, but you could try my Port Concurrency Runtime
library at
www.codeplex.com/PCR. The library is tiny and open source.
It allows various kinds of continuations and arbitrations such as:
private static void ParallelCalcTest()
{
Port<intinPort = new Port<int>();
// Register a handler that is both persistent and concurrent
(i.e. true, true).
Selector.SelectOne(true, true, inPort,
delegate(int num)
{
Console.WriteLine("Result:{0} ThreadID:{1}",num*2,
Thread.CurrentThread.ManagedThreadId);
Thread.Sleep(10); // Force a sleep to help kick-in
multiple threads for demo.
}).Run();
for (int i = 0; i < 20; i++)
{
inPort.Push(i);
}
}
The current default is using the .Net ThreadPool as the dispatcher so actual
number of concurrent threads running will depend on ThreadPool Min settings,
cpus, and what is going on in the system and if you block at all (i.e. Sleep
above) in your code.
Output on my single proc system:
Result:0 ThreadID:7
Result:2 ThreadID:11
Result:4 ThreadID:12
Result:6 ThreadID:13
Result:8 ThreadID:7
Result:10 ThreadID:11
Result:12 ThreadID:12
Result:14 ThreadID:13
Result:16 ThreadID:7
Result:18 ThreadID:11
Result:20 ThreadID:12
Result:22 ThreadID:13
Result:24 ThreadID:7
Result:26 ThreadID:11
Result:28 ThreadID:12
Result:30 ThreadID:13
Result:32 ThreadID:7
Result:34 ThreadID:11
Result:36 ThreadID:12
Result:38 ThreadID:13
--
William Stacey [C# MVP]
"Martin Pöpping" <ma******@despammed.comwrote in message
news:eo**********@newsreader3.netcologne.de...
| Hello,
|
| I´m having several loops with independent operations.
| Now I want to parallelize these loops for my two test-machines
| (a 4xXeon Server and a DualCore 2 Notebook).
|
| Does anybody know a good tutorial about parallizing with C#?
|
| Which solutions are possible?
|
| At the moment I only can imagine to do it with several threads.
| Are there other ways?
|
| Is it for example possible to run the OpenMP library
| in an unmanaged code area of C#?
|
|
| Regards,
|
| Martin