I have 3 methods and I want to execute them in parallel. Unfortunatelly, I cannot use Task Parallel Library, because I work on NET 3.5 Framework.
How to use parallelism in Net 3.5? I don't want to install any extra open source libraries etc.
Asked
Active
Viewed 106 times
0

rpax
- 4,468
- 7
- 33
- 57

apocalypse
- 5,764
- 9
- 47
- 95
-
Search for threading… – poke Apr 03 '14 at 13:01
3 Answers
2
Depending on what kind of processing your methods need to do and if they update GUI elements, you can use the following classes:
The answers in this question will help you figure out which is the ideal for your scenario.
-
I just need mathematical computation. Each computation takes ~50 ms on my cpu, so I want to do 4 computations at once. What should I use? ThreadPool? – apocalypse Apr 03 '14 at 13:11
-
Updated the answer, the answers in that question should help you figure out which method would be ideal. – coolmine Apr 03 '14 at 13:12
0
new Thread( Method1 ).Start();
new Thread( Method2 ).Start();
new Thread( Method3 ).Start();

Martin Wedvich
- 2,158
- 2
- 21
- 37
0
your methods must be Static to use multi threading first import following
using System.Threading;
then follow the following structure
Thread t1,t2,t3;
public static void method1()
{
//do some thing here
}
public static void method2()
{
//do some thing here
}
public static void method3()
{
//do some thing here
}
public void StartworkinParallel()
{
//initialize all threads here
t1=new Thread(new ThreadStart(method1));
t2=new Thread(new ThreadStart(method2));
t3=new Thread(new ThreadStart(method3));
// start them to simulate parallelism
t1.Start();
t2.Start();
t3.Start();
}
feel free to ask if any thing went wrong!

Zain Ul Abidin
- 2,467
- 1
- 17
- 29