2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
 
using System.Threading;
namespace VirtualSrm.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();
            }
        }
    }
}