using System.Diagnostics;

using System.Diagnostics;

 

using System.Diagnostics 命名空间 包含了能够与系统进程 事件日志 和性能计数器进行交互的类 一般用于帮助诊断和调试应用程序 例如 Debug类用于帮组调试代码 Process类能够控制进程访问 Trace类能够跟踪代码的执行情况

Process 用于操作本地或者远程进程打访问 通过Process 可以在托管环境下很容易的操作对外部进程的启动或者停止 

代码
复制代码
using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Text;
using  System.Diagnostics;
namespace  TestEqual
{
    
class  Program
    {
        
static   void  Main( string [] args)
        {    
            Process myProcess 
=   new  Process();
            myProcess.StartInfo.FileName 
=   " iexplore.exe " ;
            myProcess.StartInfo.Arguments 
=   " http://www.baidu.com " ;
            myProcess.Start();
        }

       
    }
    
}
复制代码

必须设置相应的FileName和Arguments属性

 

Stopwatch 用于高精度检测运行时间  Start方法表示开始测量  Stop表示停止测量 Reset 表示停止测量并重置 为0最后以Elapsed返回测量时间

代码
复制代码
using  System;
using  System.Collections.Generic;
using  System.Linq;
using  System.Text;
using  System.Collections;
using  System.Diagnostics;
namespace  TestEqual
{
    
class  Program
    {
        
static   void  Main( string [] args)
        {
            ArrayList mylist 
=   new  ArrayList();
            Stopwatch watch 
=  Stopwatch.StartNew();
            
for  ( int  i  =   0 ; i  <   100000 ; i ++ )
            {
                mylist.Add(i);
            }
            watch.Stop();
            Console.WriteLine(watch.ElapsedMilliseconds);
            Console.ReadLine();
        }


    }
}
复制代码

 

EventLog  提供了写入 读取 创建 和删除事件日志的方法

代码
复制代码
using  System; using  System.Collections.Generic; using  System.Linq; using  System.Text; using  System.Collections; using  System.Diagnostics; namespace  TestEqual {      class  Program     {          static   void  Main( string [] args)         {
            EventLog mylog 
=   new  EventLog( " MyLog " " . " " AnyLog " );             mylog.WriteEntry( " It is my log. " , EventLogEntryType.Information,  1 );              foreach  (EventLogEntry ele  in  mylog.Entries)             {                 Console.WriteLine(ele.Message);             }         }
    } }

转载于:https://www.cnblogs.com/xiao-wei-wei/archive/2012/08/04/2622441.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值