作业

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace 例8._1
{
    public class ProcessDemo
    {
        public void StartProcess(int n)
        {
            Process p;
            for (int i = 1; i <= n; i++)
            {
                p = Process.Start("calc.exe");
                Console.WriteLine("已运行{0}个计算器进程", i);
            }
        }
        public void ExitProcess()
        {
            Process[] ps = Process.GetProcessesByName("calc");
            foreach (Process p in ps)
            {
                Console.Write("请回车以结束一个计算器进程");
                Console.ReadLine();
                p.Kill();
            }
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            ProcessDemo pd = new ProcessDemo();
            pd.StartProcess(3);
            pd.ExitProcess();
        }
    }
}

 

 

只能做到这里了,再往下就不知道该怎么做了。

posted @ 2015-10-07 11:15  wpz  阅读(152)  评论(1编辑  收藏  举报