Using system. diagnostics;

Source: Internet
Author: User

Using system. the diagnostics namespace contains classes that can interact with system process Event Logs and performance counters. They are generally used to help diagnose and debug applications. For example, the debug class is used to help groups debug code. The process class can control process access to trace. class can track Code Execution

Process is used to operate local or remote process access. By using process, you can easily start or stop an external process in a hosted environment.

Code

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 ();
}


}

}

The filename and arguments attributes must be set.

 

Stopwatch for high-precision detection run time start method indicates start measurement stop means stop measurement reset means stop measurement and reset to 0 finally return measurement time with elapsed

Code

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 provides the method to write and read the Event Logs created and deleted.

Code 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 );
}
}

}
}

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.