进程与线程

进程:
1.Process 
using System.Diagnostics;  //引用命名空间

Process.Start("进程名");   //程序进程打开

Process p = new Process();  //实例化

ProcessStartInfo psi = new ProcessStartInfo(要开启的进程的绝对路径);

p.StartInfo = psi;

p.Start();

2.用默认浏览器打开网站:Process.Start("http://www.....");

3.杀死进程们:
Process[ ] ps = Process.GetProcesses();进程集合
foreach (Process p in ps)遍历进程
{
    p.Kill();杀死进程
}

线程:
using System.Threading;  //命名空间
Thread.Sleep(毫秒);  //延迟

Thread th = new Thread(委托); //创建对象
th.IsBackground = true; //设置后台线程
th.Start(); //开始执行

允许跨线程访问控件:
构造函数中,构造方法下部添加:
Control.CheckForIllegalCrossThreadCalls = false;   //关闭监控

posted on 2017-11-28 11:27  小败哥哥。  阅读(74)  评论(0编辑  收藏  举报

导航