how to call the method in thread with aruguments and return some value
- by ratty
i like to call the method in thread with aruguments and return some value here example
class Program
{
static void Main()
{
Stopwatch stop = new Stopwatch();
stop.Start();
Thread FirstThread = new Thread(new ThreadStart(Fun1));
Thread SecondThread = new Thread(new ThreadStart(Fun2));
FirstThread.Start();
SecondThread.Start();
}
public static void Fun1()
{
for (int i = 1; i <= 1000; i++)
{
Console.WriteLine("Fun1 writes:{0}", i);
}
}
public static void Fun2()
{
for (int i = 1000; i >= 6; i--)
{
Console.WriteLine("Fun2 writes:{0}", i);
}
}
}
i know this above example run successfully but if method fun1 like this
public int fun1(int i)
{
for (int n = i; n >= i+10; n++)
{
Console.WriteLine("Fun2 writes:{0}", i);
}
}
then how can i call this in thread. Is it possible .Any body Help for me