using System.Threading;
|
|
namespace iWareCommon.Utils
|
{
|
public class ThreadHelper
|
{
|
/// <summary>
|
/// 开启线程
|
/// </summary>
|
public static void StartThread(Thread thread)
|
{
|
if (thread != null)
|
{
|
thread.IsBackground = true;
|
thread.Start();
|
}
|
}
|
|
/// <summary>
|
/// 开启带参数的线程
|
/// </summary>
|
public static void StartThread(Thread thread, object obj)
|
{
|
if (thread != null)
|
{
|
thread.IsBackground = true;
|
thread.Start(obj);
|
}
|
}
|
|
|
/// <summary>
|
/// 关闭线程
|
/// </summary>
|
/// <param name="thread">需要关闭的线程</param>
|
public static void CloseThread(Thread thread)
|
{
|
if (thread != null)
|
{
|
thread.Abort();
|
}
|
}
|
|
}
|
}
|