using System;
using System.Threading;
namespace Temp2
{
class Class1
{
static void Founction1()
{
for (int i=0;i<10;i++)
Console.WriteLine("Work in Founction1.");
}
static void Founction2()
{
for (int i=0;i<10;i++)
Console.WriteLine("Work in Founction2.");
}
[STAThread]
static void Main(string[] args)
{
ThreadStart ts1=new ThreadStart(Founction1);
ThreadStart ts2=new ThreadStart(Founction2);
Thread t1=new Thread(ts1);
Thread t2=new Thread(ts2); t1.Priority=System.Threading.ThreadPriority.AboveNormal;
t1.Priority=System.Threading.ThreadPriority.Lowest; t1.Start();
t2.Start();
}
}
}
这个程序运行没有问题,但是如果函数:
static void Founction1(int n1);
static void Founction2(int n2);
执行线程如何把参数传递到函数里面?需要用委托,但是我不会用,怎么作?帮助一下,谢谢。
我想把n1,n2 传递到Founction1,和Founction2 里面去,怎么作??帮帮忙,谢谢
using System.Threading;
namespace Temp2
{
class Class1
{
static void Founction1()
{
for (int i=0;i<10;i++)
Console.WriteLine("Work in Founction1.");
}
static void Founction2()
{
for (int i=0;i<10;i++)
Console.WriteLine("Work in Founction2.");
}
[STAThread]
static void Main(string[] args)
{
ThreadStart ts1=new ThreadStart(Founction1);
ThreadStart ts2=new ThreadStart(Founction2);
Thread t1=new Thread(ts1);
Thread t2=new Thread(ts2); t1.Priority=System.Threading.ThreadPriority.AboveNormal;
t1.Priority=System.Threading.ThreadPriority.Lowest; t1.Start();
t2.Start();
}
}
}
这个程序运行没有问题,但是如果函数:
static void Founction1(int n1);
static void Founction2(int n2);
执行线程如何把参数传递到函数里面?需要用委托,但是我不会用,怎么作?帮助一下,谢谢。
我想把n1,n2 传递到Founction1,和Founction2 里面去,怎么作??帮帮忙,谢谢
[STAThread]
static void Main(string[] args)
{
a T=new a();
a.n=10;
ThreadStart ts2=new ThreadStart(a.function1);
ts2.start();
}
Class A
{
public int n=0;
private void function1()
{
}
}