进main后,直接申请thread.然后将相关参数进行ref传入form的构造函数(重写默认的构造函数即可). proc.cs类完成. using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; using System.Diagnostics; using System.Threading; namespace MJsniffer { class proc { private Process[] myProcess = null; public int sum = 0; public void GetCurrentInfo() { while (true) { myProcess = Process.GetProcesses(); string MY = Process.GetCurrentProcess().ProcessName.ToString(); int sum1 = -1; foreach (Process pr in myProcess) { pr.Refresh(); string[] str = { pr.ProcessName, pr.Id.ToString(), pr.Responding==true?"正在运行":"失去响应" }; if (str[0] == MY) { sum1++; } } //MessageBox.Show(sum1.ToString()); //guard thread /* if (sum1 < sum) { Process.Start("MJSniff.exe"); } */ sum = sum1; Thread.Sleep(10000); } } } } 主函数入口处: using System; using System.Collections.Generic; using System.Windows.Forms; using System.Threading; using System.Diagnostics;//process namespace MJsniffer { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { //Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal;//get a high priority proc ProcList = new proc(); Thread th_Proc = new Thread(new ThreadStart(ProcList.GetCurrentInfo)); th_Proc.Priority = ThreadPriority.Normal; th_Proc.Start(); Thread.Sleep(1000); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MJsnifferForm(ref ProcList.sum)); } } } 窗体构造函数: public MJsnifferForm(ref int input) { procn = input; MessageBox.Show(procn.ToString()); InitializeComponent(); }