Hi Gerard,
I have posted some fairly simplistic code below. Just create a console application in C# and try it. A few things to remember. You can set the threads to be background threads; I haven't on this occasion. Also, you could use the .NET ThreadPool to do this which will use background threads by default. If you want to use the ThreadPool, let me know and I will provide some alternate code. I have passed the name of the delegates on the assumption that the compiler will use delegate inference. You can wrap a delgate around the target method names but it's not required.
HTH
-=Gary
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
Program prog = new Program();
Thread thread1 = new Thread(prog.Loop1);
Thread thread2 = new Thread(prog.Loop2);
thread1.Start();
thread2.Start();
}
public void Loop1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Loop1 at iteration {0}", i);
Thread.Sleep(1000);
}
}
public void Loop2()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine("Loop2 at iteration {0}", i);
Thread.Sleep(1000);
}
}
}
}
>Hi.
>Anybody know how to run a no. of threads concurrenly (in either c# or c+++
>e.g.
>say loop 1 loops arounf displaying 'This is Loop 1'
>and Loops 2 loops around saying 'This is loop 2'
>
>Regards,
>Gerard
-=Gary