C# 在webBrowser.DocumentCompleted中计算计时
我们如何计算时间?我的意思是当按下时,点击它的应该开始(时间),当完成加载页面比停止。当你在谷歌搜索时,它会告诉你需要多长时间C# 在webBrowser.DocumentCompleted中计算计时,c#,.net,winforms,webbrowser-control,C#,.net,Winforms,Webbrowser Control,我们如何计算时间?我的意思是当按下时,点击它的应该开始(时间),当完成加载页面比停止。当你在谷歌搜索时,它会告诉你需要多长时间 /* foreach (string bug in bugs) { webBrowser.Navigate(new Uri(url)); webBrowser.Document.GetElementById("product").SetAttribute("value", product); webBrowser.Document.GetElem
/*
foreach (string bug in bugs)
{
webBrowser.Navigate(new Uri(url));
webBrowser.Document.GetElementById("product").SetAttribute("value", product);
webBrowser.Document.GetElementById("version").SetAttribute("value", version);
webBrowser.Document.GetElementById("commit").InvokeMember("click");
//Need code to wait for page to load before continuing.
} */
我想你可以用秒表来测量时间,看看下面的例子
using System;
using System.Diagnostics;
using System.Threading;
class Program
{
static void Main(string[] args)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
Thread.Sleep(10000);// here your code
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
ts.Hours, ts.Minutes, ts.Seconds,
ts.Milliseconds / 10);
Console.WriteLine("RunTime " + elapsedTime);
}
}