Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在webBrowser.DocumentCompleted中计算计时_C#_.net_Winforms_Webbrowser Control - Fatal编程技术网

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