天涯尽头无女友
如果您需要评估返回值的代码,请使用 Task EvaluateScriptAsync(string script, TimeSpan? timeout) 方法。Javascript 代码是异步执行的,因此使用 .Net Task 类返回响应,其中包含错误消息、结果和成功 (bool) 标志。// Get Document Heightvar task = frame.EvaluateScriptAsync("(function() { var body = document.body, html = document.documentElement; return Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); })();", null);task.ContinueWith(t =>{ if (!t.IsFaulted) { var response = t.Result; EvaluateJavaScriptResult = response.Success ? (response.Result ?? "null") : response.Message; }}, TaskScheduler.FromCurrentSynchronizationContext());