展开全部
我给你个 带参数的线程吧:
using System;
using System.Threading;
/// <summary>
/// Summary description for Class1
/// </summary>
namespace EmailJob
{
public class SimpleThread
{
public delegate void Start(object[] o);
private class Args
{
public object[] o;
public Start s;
public void work()
{
s(o);
}
}
// start委托名称, arg 参数列表。
public static Thread CreateThread(Start s, object[] arg)
{
Args a = new Args();
a.o = arg;
a.s = s;
Thread t = new Thread(new ThreadStart(a.work));
return t;
}
}
}
// demo
// using ...... 省略
namespace EmailJob
{
public void RunOK()
{
System.Threading.Thread thr = SimpleThread.CreateThread(new SimpleThread.Start(代理的函数名), new object[] { 你的参数 });
thr.IsBackground = true;
thr.Priority = ThreadPriority.BelowNormal;
thr.Start();
}
}
using System;
using System.Threading;
/// <summary>
/// Summary description for Class1
/// </summary>
namespace EmailJob
{
public class SimpleThread
{
public delegate void Start(object[] o);
private class Args
{
public object[] o;
public Start s;
public void work()
{
s(o);
}
}
// start委托名称, arg 参数列表。
public static Thread CreateThread(Start s, object[] arg)
{
Args a = new Args();
a.o = arg;
a.s = s;
Thread t = new Thread(new ThreadStart(a.work));
return t;
}
}
}
// demo
// using ...... 省略
namespace EmailJob
{
public void RunOK()
{
System.Threading.Thread thr = SimpleThread.CreateThread(new SimpleThread.Start(代理的函数名), new object[] { 你的参数 });
thr.IsBackground = true;
thr.Priority = ThreadPriority.BelowNormal;
thr.Start();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询