WebBrowserオブジェクトを学習するための簡単な自動サーフィンアプリを作成しています。
数秒ごとにネットサーフィンしている23のURLのリストがあります。
アプリはシンプルです。フォーラムにアクセスし、フォームを開いて新しいメッセージを(送信せずに)追加し、リストの最後に到達するまで続行します。
私の問題は、コードforumAction.FillOutFormIn(webBrowser1.Document);
が間違ったサイトで実行されることです。
これは、ドキュメントの準備ができていないために発生したと思います。
では、ドキュメントの準備ができるまで、タイマーがコードを実行するのを停止する方法はありますか?
TIMER TICK
関数は次のとおりです。
//I start is in 21 for faster testing.
int timesToRun = 21;
private void Time_Tick(object sender, EventArgs e)
{
Console.WriteLine(timesToRun.ToString());
string currentSite = siteList.GetSiteFromIndex(timesToRun);
webBrowser1.Document.Window.Navigate(currentSite);
//I think I need to wait here until the document is ready
//this line of code doesn't run on timeToRun = 22
forumAction.FillOutFormIn(webBrowser1.Document);
Console.WriteLine(webBrowser1.Url);
timerLabel1.Text = siteList.SiteLists.Count + ">" + timesToRun + "";
if (timesToRun >= siteList.SiteLists.Count - 1)
{
enableControls(true);
timesToRun = 0;
timer.Stop();
Console.WriteLine("done");
}
timesToRun++;
}
(私の英語でごめんなさい)