я хочу запустить DocumentCompleted в цикле - PullRequest
0 голосов
/ 21 сентября 2019

Я хочу подготовить страницу HTML для печати. ​​Я хочу выполнить DocumentCompleted в цикле, но он не будет работать до конца цикла. Для отправки при каждом выполнении цикла команды печати. ​​

string _filesPrint = "";
string _filesDesign = System.IO.File.ReadAllText(Path.GetDirectoryName(Application.ExecutablePath) + @"\printerDesign\files.html");
int countFilesPrepare = 0;
foreach (DataRow _dtRows in _dt.Rows)
{
    _filesPrint = _filesPrint + _filesDesign;
    countFilesPrepare++;
    lblFilesPrepare.Text = "total files for print : " + 
    countFilesPrepare.ToString();
    lblFilesPrepare.Update();
    if (countFilesPrepare % 2==0)
    {
        myWebBrowser.DocumentCompleted += myWebBrowser_DocumentCompleted;// this line not execute
        myWebBrowser.DocumentText = (_filesPrint);
        _filesPrint = "";
        _filesDesign = System.IO.File.ReadAllText(Path.GetDirectoryName(Application.ExecutablePath) + @"\printerDesign\files.html");
        myWebBrowser = new WebBrowser();
    }
}
if (_filesPrint != "")
{
    myWebBrowser.DocumentCompleted += myWebBrowser_DocumentCompleted;
    myWebBrowser.DocumentText = (_filesPrint);

}
...