この質問について非常に多くのリンクを試しましたが、ヘルプが見つかりませんでした。Webページからデータを取得し、リストボックスに結果を表示する.exeファイルを実行するこのコードがあります。これには時間がかかり、ウィンドウがフリーズします。BackgoundWorker を使用することにしましたが、すべての例でループを使用して進行状況バーを更新します。私の場合はループがありません。進行状況バーをインクリメントするにはどうすればよいですか? これについて私を助けてください、これが私のコードです、
labelstat.Text = "Please wait..";
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "Out.exe";
p.Start();
// Do not wait for the child process to exit before
// reading to the end of its redirected stream.
// p.WaitForExit();
// Read the output stream first and then wait.
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
checkedListBox1.Items.AddRange(output.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries));
これを貼ってみたのですが、
backgroundWorker_DoWork
バックグラウンドでタスクを実行する方法ですが、コードによって実行されるプロセスに従ってプログレスバーをインクリメントする方法がわかりませんか? :( どうもありがとうございます..