在 webBrowser.DocumentCompleted 中计算时间 [英] calculate timing in webBrowser.DocumentCompleted
本文介绍了在 webBrowser.DocumentCompleted 中计算时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何计算时间?我的意思是当按下点击它应该开始(时间)和完成加载页面而不是停止.当你在谷歌搜索时,它会告诉你需要多长时间.
How can we calculate timing? I mean when pressed click it's should start(time) and when finished load page than stop. when you searching in google, its shown you a time how long it takes.
/*
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.
} */
推荐答案
我觉得你可以用StopWatch classe来测量时间看下面的例子
I think you can use StopWatch classe to measure time look at the following example
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);
}
}
这篇关于在 webBrowser.DocumentCompleted 中计算时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文