winform学习之----进程和线程

时间:2023-03-09 09:44:00
winform学习之----进程和线程

Process[] pros = Process.GetProcesses();//获取多个进程
            foreach(var item in pros)
            {
                item.Kill();
                Console.Write(item);
            }

Process.Start("calc");//打开计算器

ProcessStartInfo psi = new ProcessStartInfo("@...");
            Process p = new Process();
            p.StartInfo = psi;
            p.Start();

Thread th = new Thread(test);//开启线程
            th.Start();
            th.Abort();
            th.Start();

if(th!=null)
            {
                th.Abort();//终止线程
            }

//在.net下,不允许跨线程的访问处理办法:Control.CheckForIllegalCrossThreadCalls = false;