【发布时间】:2017-05-31 08:10:22
【问题描述】:
我在 Cefsharp 中使用 EvaluateScriptAsync 时遇到问题。我想用 EvaluateScriptAsync 运行一个 javascript 代码,然后在完成后我希望我的代码继续工作,但 ContinueWith 不等待 EvaluateScriptAsync 完成。这是我的代码,不知道是什么问题:
private void WebBrowserFrameLoadEnded(object sender, FrameLoadEndEventArgs e)
{
if (e.Frame.IsMain)
{
var task = browser.EvaluateScriptAsync("(function() { function xx() { $('body').animate({scrollTop: $('body').prop(\"scrollHeight\")}, 8000, function() { var win = $(window); if ($(document).height() - win.height() == win.scrollTop()) { return true; } else { xx(); } }); }; xx(); })();");
task.ContinueWith(taskHtml =>
{
if (taskHtml.IsCompleted)
{
/* Some code working */
}
this.DialogResult = DialogResult.OK;
});
}
}
【问题讨论】:
-
你没有查看脚本是否执行成功,查看任务结果
-
@amaitland 脚本正在运行,我已经检查过了。
-
请更新您的代码以显示您检查响应的位置。